Answers for "Aim preview for projectile trajectory"
http://answers.unity.com/questions/156571/aim-preview-for-projectile-trajectory.html
The latest answers for the question "Aim preview for projectile trajectory"Answer by jyounger
http://answers.unity.com/answers/157603/view.html
Actually, I take it back. After looking at the Rochard trailer again, it seems that the trajectory being drawn and the actual flight path of the boxes being shot are in fact a parabolic trajectories that don't take drag into account.
I've talked to two math guys about this (including the fellow who made that physics applet I linked to) and I've gotten two different answers, neither of which has worked out very well:
X = initialVelocity*cos(initialAngle)
Y = initialVelocity*sin(initialAngle)
loop N points times(
X = X - (1/2) * drag * (velX*velX) * tStep/mass
Y = Y - (1/2) * drag * (velY*velY) * tStep/mass - grav*tStep
)
and
X = X + mass/drag*initialVelocity*cos(initialAngle)*(1-e*(-drag*tStep/mass))
Y = Y + mass*gravity/drag*tStep+mass/drag*(initialVelocity*sin(initialAngle)+mass*gravity/drag)*(1-e*(-drag/mass*tStep))
The first one actually works a bit better, though drag appears to only be affecting things in a leftward direction. It's hard to tell though because the gravity is behaving very strangely and seems to change directions depending on the initial angle.
The second one doesn't seem to even begin aiming in the proper direction, which at least the first one does.
Man, why is this so hard :(Wed, 17 Aug 2011 19:28:57 GMTjyounger