Skip to main content
gamedev.net
🔒 Locked

Projectile?

Started by ThornBitter Jan 2, 2004 at 11:50 AM 2 replies 400+ views
Original Post
ThornBitter
ThornBitter
Hi Friends, I want to make a simple projectile. My tank will fire and it should animate like a projectile. Plz help me in PHYSICS. Pride
<>
Kaezin
Kaezin

CTank Tank;
Tank.Fire();

Simple as that.

What is your question? I need help isn't a question.

[edited by - Kaezin on January 2, 2004 1:02:37 PM]
Half the people you know are below average.Trogdor the Burninator
TerranFury
TerranFury
A projectile leaves a gun with some initial velocity. Velocity is a vector. Picture a vector as an arrow: It has a length AND a direction. Read the simple stuff on vectors here in Gamedev's Articles and Resources section.

Each frame, gravity accelerates your projectile downward. It is a constant acceleration. You can do this by adding each frame the vector 'g*(0, -1, 0) * deltaT' to your velocity.

Then, each frame, add your velocity to your position.

The technique of keeping track of velocity and position and adding each frame is called Euler integration. Google for this term.

How would I implement this? One simple way is with a list of bullet objects. Whenever a tank fires, add a bullet to the list. Each frame, also check to see if any bullet has collided with any tank, and perform the appropriate actions (subtracting health points, etc). Each bullet object in the list could have a position and a velocity, both of which are vectors.

[edited by - TerranFury on January 2, 2004 2:49:32 PM]

Topic Locked

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

Sign in to reply to this topic.