Best way to implement jumping to prevent multijumps

Hello and happy new year

Just a quick question I have when implementing jumping

What is the best way to implement jumping in a fps game to combat multiple jumping? How do AAA games usually implement jumping?
Do they use multiple raycasts underneath the player to check the radius of the players base and detect collision underneath the player accordingly? Are these raycasts fired when the player is in the air only or is there a constant raycast checking the base of the player at all times? and if so how expensive is this? or is there a better way to optimise this?

Or is a date function added in order to add jump times and limit them to certain intervals?

Just wanted to get some thoughts in implementing it. Thanks!

Hi @nasjarta,

All suggestions are valid, and based in your gameplay and the precision you require you can select the appropriate one.

Casting a ray from the player’s feet can be done per frame, if required, even if using physics a single raycast isn’t that expensive.

1 Like

1 raycast doesn’t do the job i think you would need multiple raycasts checking the entire base of the player in order to not miss any spots colliding between player and ground. Would multiple raycasts be expensive?

Would you say its better to use multiple raycasts or check if there is a collision with the ground? Or using both methods together? I am curious because I did not find the best way to implement jumping in an FPS and maybe I am thinking too much. Is it just preference?

Hi @nasjarta! For the first version of my own game I used multiple raycast to detect the ground, because with one raycast the player can easily fall in a too narrow space between objects. Apart from that I think one raycast can do the job perfectly. Alternatively you can check the project of @LeXXik with for example a spherecast.

https://playcanvas.com/project/695416/overview/sphere-cast-for-hit-detection

1 Like

For the newest version of my game I use a dynamic rigidbody and check the lineair velocity to know if the player is falling or grounded.