I have a projectile with known position, velocity and gravity. How do I predict where it will be in the future and where it will hit a wall?

+1 vote

You can create a "ghost projectile" which basically calculates what your projectile will do and just let the physics engine do the calculations for you. You also get the added benefit of graphical feedback of the calculation.

Alternatively you can use the projectile motion formula. Just do a google search on that, there is a lot of information about it.

Since you also need to calculate where it would hit a wall, the first method is probably the easiest, since you're gonna have to trace the projectile's path and test for collision each step.

To make the calculation instantaneous, you can also scale the velocity and gravity of the "ghost projectile"

- All categories
- Engine 15,871
- Projects 1,886
- Gossip 259

I think this is quite a nice idea to begin with, especially for things like implementing AI to shoot projectiles.

For using formulas to solve trajectories, this article is pretty elaborate upon the first glance.