|
-
Senior Member
It strikes me that a click at (C) and a click at (A) are doing two very different things in this example... when clicking (C), the player is clicking at the top of the arc that the character is supposed to leap to. Clicking (A) on the other hand is clicking the endpoint of an arc, and you're asking for the code to differentiate that type of click and come up with a higher midway point to be the top of the requested arc.
The way around this I guess is to think about (C) as an end-point, too. If that's true, than to get to either (C) or (A), the character will have to jump higher than those points. How much higher depends on how far the character is going to move horizontally, how quickly they're going to move horizontally, and how much vertical velocity they're going to lose.
Assuming you have a constant gravity acting on the character's y-velocity, and assuming the x-velocity is going to be constant throughout the jump, you should be able to take the horizontal distance divided by two and figure out how long in ticks the character will take to complete the second half of the arc in x-distance. If you know that, just create a scratch acceleration var and run it that many times in a loop, adding the value of itself+gravity each time, and the y-position of the end point minus that total gravity should give you the top of a parabola that's halfway between start and finish and at the right height above the endpoint to make the jump look realistic.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|