I’m trying to determine, before allowing a character to jump, where they will land. I’m going to change the behavior of the jump, based on the results of this prediction. What’s the best way to predict the landing location of a character who is about to have some jump velocity applied?
Just to be clear, I’m really looking to include information about collisions along the way in the prediction. As stated below, just following the parabola formed during the jump will get me the landing location, as long as nothing collides with the jumper along the way. That’s not terribly useful in the game, however, since there might be other platforms or objects that cause a collision.
Is there a way to cause a physics sweep to follow the path of the jump?
You can get a simple approximation (assuming flat ground) as follows:
Calculate 2*Z/g, where (X, Y, Z) is the jump velocity and g is the UE4 variable “Gravity Z”. Call the answer k.
The landing position is the original position plus (Xk, Yk, 0).
Taking into account the landscape or objects the character can land on would involve intersection with a paraboloid (see Rama’s answer), but perhaps casting a ray upwards from the above approximation would be enough for your needs.
@cuwaters Is this still a problem for you? I had to solve what I believe is a similar problem for my physics vehicle game. Let me know and if so I’ll post the algorithm I wrote to predict the landing location and adjust the jump accordingly. My implementation is for physics movement, but it can be adapted for kinematic bodies.
Yes, it’s still something I’d like to do. I’ve come up with some sub-standard workarounds, but your video looks much better than anything I’ve gotten working. I’d definitely appreciate knowing more about how you accomplished it.