user1485689
user1485689

Reputation: 35

How can I find the closest flat area to the main character in Unity?

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.

enter image description here

Upvotes: 0

Views: 173

Answers (1)

Absinthe
Absinthe

Reputation: 3391

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

Upvotes: 2

Related Questions