Sometimes my main character gets stuck like this and if he stays in the air like this for 2-3 seconds, I want to move the main character to the nearest flat area. (The surface angle can be between 0f to 60f with a minimum 0.5f radius empty space)
How can I find the closest flat area to the main character in Unity?
Thank you so much.
CodePudding user response:
Raycast (or a similar method in the Physics class e.g. spherecast
). From the RaycastHit get the normal of the hit and assess if it's angle is suitable using Vector3.Angle