Is this actually possible to draw an arc of the where the crossbow bolt will go
I've been researching these and trying to implement into my lua scripts, but I can't seem to get it working
https://en.wikipedia.org/wiki/Projectile_motion
I will provide the code I've attempted below, if anyone has any better pointers for me. That would be greatly appreciated
local shootPos = LocalPlayer():GetShootPos()
local eyeTrace = LocalPlayer():GetEyeTrace()
local aimPos = eyeTrace.HitPos
local dist = shootPos:Distance(aimPos)
local v = 3500
local g = 0.05
local a = (shootPos.x - aimPos.x)^2
local b = (shootPos.z - aimPos.z)^2
local r = math.sqrt(a+b)
local sol = math.deg(math.asin(g*r/v^2))/2
local sol2 = 90 - sol
--unsure of where I can really go now, but i feel like i'm on sorta the right track
print(sol)
I'm trying to calculate where the bolt will land, preferably in the future I would like a visual representation of the arc, from shootpos, to where it lands.
Someone has already done it, but I don't think it was ever publicly released. You could try asking them (if they are still active) to point you in the right direction, here is the link:
https://www.youtube.com/watch?v=h9MiucXPLuY
It seems he doesn't reply to comments so I doubt if I asked he would reply.
I'm just struggling to work a forumla out.
I know the bolt travels at 3500 u /s
and obeys a different gravity than the servers gravity (0.05)
if you would like a formula for the position of the bolt with respect to time given the initial velocity and launch angle
the horizontal speed is a constant 3500, so the horizontal distance traveled is just x(t) = 3500 * t
the vertical speed depends on the aim angles and has a constant acceleration of 0.05 u/s^2 down, so we can use the formula s = vt - 0.5*at^2 to get y(t) = (initial vertical velocity)*t - 0.5*0.05*t^2
Sorry, you need to Log In to post a reply to this thread.