I'm making some rudimentary AI for my side-scroller and I need to know whether an AI unit can reach point B from point A simply by taking a jump.
Flight trajectory of my characters is a bit unusal as they can apply force in mid-air (like in Jazz Jackrabbit 2 for example), so unlike the classic trajectory of a projectile which is about...
path that a thrown or launched projectile will take (...) without propulsion.
... I suppose that my problem is more about a projectile with propulsion (e.g. rocket).
To illustrate this, this is how the flight curve looks like for my character if I jump and continually press the "left button" (it looks different at the left end, this is where I was making some manuevers in mid-air):
The force applied during flight is always parallel to the X axis, so it is F = (-f, 0) if I hold "left" and it is F = (f, 0) if I hold "right".
He can move very much like a ski jumper:
So it differs a lot from the classic trajectory which is simply a parabola (source: wikipedia):
To make it more difficult, I am simulating simple air resistance so my characters can accelerate only up to some maximum speed value.
This is done by applying a small force in the opposite direction of travel:
b2Vec2 vel = body->GetLinearVelocity();
float speed = vel.Normalize(); //normalizes vector and returns length
body->ApplyForce( AIR_RESISTANCE_MULT * speed * speed * -vel, body->GetWorldCenter() );
The AIR_RESISTANCE_MULT is a constant that in my case equals 0.1.
Let's assume that my character is an infinitely small point.
And I'm NOT taking obstructions into consideration, so my question goes like this...
How to determine (at least reliably guess), given initial velocity V, an impulse J = (0, -j) that I apply to the character upon jump, gravity G = (0, g), force F = (+-f, 0) continually applied during flight and AIR_RESISTANCE_MULT if we really decide to take air resistance into account (this is optional) , whether a point lies below the curve drawn by the path my character will take?
I have literally no idea where to start with the calculations and in fact, I am not necessarily interested in an exact answer; a well working hack/approximation would be great as the AI by no means needs to act perfectly.
edit: I've decided to solve this using simulation as Jason suggests, but how to handle such a case?
Should I draw a segment from C to D and check whether the desired point lies below this segment?
Or should I binary search the timesteps between C and D to look for the point that is close enough in horizontal distance to the desired point, and only then check the vertical difference? (seems a bit overkill to me)