- Home /
how can i detect ledges for the player and make him get up
the issue is idk how to do it should i make a lot of raycasts or a checksphere ? how can i make conditions for it to work like when its detected or not i wanna avoid using colliders but im really stuck with it i tried raycasts but didnt know where to put them and when the player is on ledge
Answer by KloverGames · Nov 18, 2021 at 01:34 PM
Just make a raycast from the player and it when it collides with a ledges checksphere you can climb onto it. I guess I can show you some code if you need further help
i dont understand so if the raycast hits i checksphere for what exactly ? do i make a state for the player where he stayes on the ledge to disable gravity ?
You can freeze your player in place.
rigidbody.constraints = RigidbodyConstraints.FreezePositionY;
This code basically makes it so the Rigidbody stays in the air. You should probably freeze the rigidbody’s position on the z-axis too if you want the character to be able to just climb side to side while on the ledge.