What’s better for ground detection, Physics.CheckSphere() or Physics.Raycast()?
1 Answer
1Hello @ShuvashisShrestha,
There is no “better” it all depends on what you are trying to achieve, if your character is big or with a large base then it’s better to use a CheckSphere or a SphereCast.
CheckSphere doesn’t provide much info of the collider it touched so it’s specific to checking if there is a collision or not
In a case where you need the normal of the terrain for IK alignement (for example correctly placing the feet on the floor) you would prefer using a Raycast and work with the hit.normal
When you want to check if the player is grounded you have many options and trying each of them to find what suits you better would be a good thing. Most people use Raycast because it’s cheap on the performances and gives a lot of informations on the collider touched but if the player is big and you still need infos on the ground you will prefer a SphereCast which is like a Raycast but instead of a dot (ray) it will cast a sphere of the desired radius (it can also be useful if you want to shoot bullets but make it easier for the players to hit the target)
I hope it helps