Share this post

Link to post

Share on other sites

Found by googling "projectile motion equations" (give that a try to look at some 500,000 hits): projectile trajectory equations are discussed well here. Those equations are based on initial velocity, rather than "force as input." Assuming by "force" you mean something related to the initial propulsion for the projectile, just convert the initial impulse (force x some-short-time) on the projectile mass to initial velocity.

That link discusses the angle to hit particular coordinates if you know your target. To determine if the projectile hits something as it travels, use small increments of time and do your collision detection using calculated x(t) and y(t) values.

I'm not familiar with DDTank, and can't help you with Python, I'm afraid.

2

Share this post

Link to post

Share on other sites

I think googling "projectile motion equations" is going to direct you more toward equations that will help you answer 'where will it land' or 'what launch angle should I use' kind of questions, they'll be useful for AI aiming no doubt.

If you want the sort of projectile movement you see in DDTank (which from a cursory googling looks like a worms clone to me), then you're probably more interested in frame by frame movement. Which is even simpler.

You're going to have 3 vectors:

Acceleration (gravity)

Velocity

Position

Each update you need to know the duration of the frame/tick (dt = delta time).

void UpdateProjectile(float dt)

{

Position += Velocity*dt;

Velocity += Acceleration*dt;

if (CollisionTest())

{

Kaboom();

}

}

Updating the position/velocities of physics objects is known as integration, and that function is the simplest most intuitive approach and should work fine for your needs. There are better approaches which reduce calculation error slightly (verlet integration for example), but that's probably not necessary at this point.

2

Share this post

Link to post

Share on other sites

This topic is 1114 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.