Skip to main content
gamedev.net
🔒 Locked

Physics

Started by cgibson Oct 21, 2000 at 10:09 PM 2 replies 650+ views
Original Post
cgibson
cgibson
Hey, I have a physics question. I want to make a demo of shooting a projectile from a turret and calculate the correct flight path. I am having a little bit of trouble, so I was wondering if anyone had any ideas that worked for them. So far, none of my ideas are working. I guess I have no idea of what to do. If anyone can help me, I would appreciate it... Thanks in advance.
jaxson
jaxson
For your projectile, you need to keep track of position, direction, and speed. Then, every frame or so, you should adjust the speed and direction of your projectile based on outside influences like gravity or wind.

I don''t know how much math you know, but you are really just keeping track of your velocity vector. Every vector has a component along each axis. For example, in a 3d simulation, your velocity vector has an x, y, and z component.

Let''s suppose that you only want to deal with gravity. Gravity would have a vector of 9.8 m/s in the negative y direction (assuming that y is up and down in your system with positive going upwards). Then, every second, you would subtract 9.8 m/s from the y component of your velocity vector.

Does that make sense? Hopefully, I haven''t been too confusing (or made any glaring mistakes ). Wind and other factors would work the same way. You just move your projectile one ''step'' along its current path and then update its velocity.

Good luck!
JonnyQuest
JonnyQuest
Well, actually, you don''t subtract 9.80665 () m/s every second. The formula for velocity is:

v(t) = a * t + v(0)

where a is acceleration, t is time, v(0) the starting velocity.

The current y position is:

y(t) = a/2 * t² + v0 * t + y(0)

OK...
y(0) is the height you throw it from (i.e. 1.5m for example)
v(0) is the starting speed in the y direction. Probably 0 for you. [m/s]
a is acceleration again [m/s²]
and
t is the time since firing (in seconds)

a = -9.80665m/s² (-9.8 is near enough) = gravitiational acceleration

I''m assuming you''re shooting the projectile horizontally here. If not, simply post and I''ll give you formulas for throwing it at an angle.

Hope I could help

- JQ, PWC Software
"There are no pessimists, optimists and realists; just pessimists and optimists who think they're realists" -me
~phil
Painless
Painless
There''s a biggy document on the forces moving a flying bullet somewhere. Search yahoo for it, it''s somewhere on the physics side.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.