Normally, I would not have a problem with this. You just give a projectile a initial position, starting velocity, and optionally some movement behaviour. Let the physics do their work, sit back and enjoy the show.

However, in an RTS you can't just let the user control exactly where the projectile goes, you want to let the user assign a target position(or unit) to shoot at, for one (or multiple) of his units, calculate the ideal trajectory, and the start velocity needed to achieve it.

This is the problem: the trajectory. Because in my RTS, there can be a significant height difference between certain locations on the map. There could be a mountain peak in the way for example.

One way to achieve it, might be this: doing a box collision test with the scene, along the [pi,pf] line. See what collision meshes collide with the box. From those meshes, create a 2 dimensional convex hull in the plane along [pi,pf]. Compute the bounding quadratic function of the convex hull (not sure how to do this). Then from that parabola, compute the startvelocity needed to achieve the projectile following the trajectory.

This might be a little overkill performance wise... considering you could have 500 units shooting at each other at the same time.

Is there any better way to approach (or fake) this?

If there isn't, then how would I compute a bounding parabola from a convex hull?

EDIT: actually convex hull is a pretty bad idea. I would need to find the "lowest" possible quadratic equation along the plane that doesn't collide and goes from pi to pf... no idea how to do that at all

Thanks

**Edited by Xcrypt, 25 May 2012 - 04:44 PM.**