|
-
You want the gradient at any point of the curve traced by the shell as it zooms through the air.
If it leaves the ground with horizontal velocity H, and vertical velocity V,
then by my reckoning the angle you're looking for at any point on its trajectory is
Code:
Math.atan(V/H - g*x/Math.pow(H,2))
where V,H are the initial velocities as already stated,
g is the acceleration due to gravity (roughly 10 metres per second, per second)
and x is the horizontal distance travelled since being fired.
My guess is you're going to have to play around with the value you give g until you get something that 'looks right' but hopefully this will give you enough to make a start.
EDIT: That's the angle between the trajectory and the horizontal by the way.
Last edited by DiamondDog; 06-17-2008 at 01:13 PM.
-
After looking through my code and at the formula given, I can get all but gravity. Should I just try working with a hard-coded number for gravity, or is there a way I could "make" gravity with the FPS of the Flash and aspects of the engine that define gravity?
-
I don't know how these engines work, so it's diffcult for me to advise you.
My guess is you could start with a hard-coded value for g and play around with it until you get something that looks right.
If it helps, the horizontal range of a shell - that's the distance it travels horizontally before coming back down to earth (assuming it doesn't hit anything on the way!) - should be 2HV/g (assuming no air resistance).
-
Ok, tried inputting a hard number. Actually, I used several. Each time, I hit the same thing: The numbers were simply TOO small to be of any use to me.
This, of course, could be because of the velocities, but I doubt it.
I used the same formula, got the values for the initial vertical and horizontal velocities, got the distance traveled, and hardcoded a gravity that accurately matched the force I used earlier to "create" gravity. However, the results always came out to be between -0.1 and -0.2, which just seemed useless to me. Is there anything missing by chance?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|