- Home /
Check if Rigidbody collider is grounded
There has been many posts that describe this, but none of them have worked for me. The problem is that I want to check that a rigidbody collider of the character touches the floor, also in slopes and inclinated surfaces, also when it falls with gravity, any good idea?
Answer by Spy-King · Sep 28, 2015 at 06:29 AM
There are many things you can use - (i work in C# so feel free to translate into JS if you use that :)
this is what i use
public void PlayerCollision() { %|-1345202661_1|% if (isGrounded) %|164386165_3|% %|826609863_4|% %|1104717570_5|% }
This works good on even surfaces. Just experiment around with the direction of the raycast. The GroundCheck is a transform which is under the Player object. You can place it according to your player's dimensions. Ground is a variable for the layermask which is used by the floor or the ground on which the player is standing.
Hope this works :)