AI Jump Arc Calculation
Thank you for taking the time to read my question, I will try to keep it as concise as I can.
I am making a 2D-platformer game. I am in the process of programming AI that can intelligently traverse their terrain. AI are able to jump, in a fashion similar to many other 2D-platformers:
* When the AI jumps, it is given a fixed initial Y-Velocity.
* The AI has a flexible time where it may ignore gravity to give it a variable jump height/air time. 229
(This mimics the way that the player is able to jump, where the player character may jump higher if the player holds down the jump-button longer.)
* After this time expires, or the AI "releases the jump button", gravity begins to affect the jump arc. The acceleration rate of gravity is also constant.
* The velocity on the X-axis is constant once the jump starts, but may be set up to a maximum prior to the jump starting.
Question: How would an AI find the minimum amount of time that it will have to "hold down its jump button" to clear an expanse between a starting jump point, and a desired target?
Details
I don't know how helpful the following is, but decided that it would be better to include more rather than less info.
* Initial Y-Velocity = 600 px/sec
* Gravity Acceleration = 2100 (px/sec)/sec
* Maximum X-Velocity = 220 px/sec
* Maximum amount of time that the AI's Y-Velocity is unaffected by gravity = .2 secs
I'd like to emphasize that the area where I really struggle is that the process of the jump may be broken up into two parts: the first part is linear, and the latter part is parabolic. The linear part is also variable and in the control of the AI, the latter part is not in the control of the AI and simply follows the parabolic path of the physical forces of the game, so the real question that the AI needs to answer is, "How long do I hold down my 'jump button'?"
I've spoofed a mock-up of what the arc of the jump looks like to visualize the issue. 229