I need the algorithm to animate the arrow based on 2 parameters, angle while shooting and power while drawing the bow. Ive tried to use y=asinx but it works only when shooting in up direction. Doesnt work well while shooting with straight or down direction. Thanks.
+6
A:
You could try simulating the motion instead of deriving the analytic function. i.e. keep track of the current position, velocity and acceleration vectors for the arrow, and each time-increment, update the position based on the velocity and the velocity based on the acceleration.
otherwise, if you need an analytic function, See @bnaul's answer for the analytic version
Jimmy
2010-03-16 00:40:15
Simulating the motion would require extra logic compare to using function. Could you describe what is x, y, a, b, c here?
Ricky
2010-03-16 00:59:13
Why use a slow and inaccurate brute-force solution to a trivially-solvable analytic equation?
Rex Kerr
2010-03-16 03:36:14
@Rex: because the usual game-related case involves non-analytic components -- collisions with arbitrary terrain shapes or objects, for example.
Jimmy
2010-03-16 16:34:53
@Jimmy: Intersection of a quadratic flight path with a triangle in the terrain is also easily analytically solved (i.e. use the quadratic formula). You still might want to do time stepping, but then you take steps along the analytic solution.
Rex Kerr
2010-03-16 17:26:02
+1 for correct answer. This is how it's done in actual games. If the world is in any way complex - for instance, you have to hit a moving target, or one of non-trivial shape - this is far *far* simpler than using equations of motion.
BlueRaja - Danny Pflughoeft
2010-03-16 23:25:37
+9
A:
The flight of your projectile is described by
x(t) = v * cos(theta) * t
y(t) = v * sin(theta) * t - 1/2 * g * t^2
where t is time, v the initial velocity (power), theta the angle, g the acceleration due to gravity (e.g. 9.8 m/s^2), x the horizontal coordinate and y the height.
bnaul
2010-03-16 00:47:15
Power = how hard you can pull the bow back, stored energy, or velocity, I wonder? The first two are proportional to v^2, not v.
Rex Kerr
2010-03-16 03:40:49