How can we make sure the Agent is always perpendicular to the walkable surface to avoid having the character going through the surface?

Thank you.
How can we make sure the Agent is always perpendicular to the walkable surface to avoid having the character going through the surface?

Thank you.
Hey!
Usually you want to have a trigger collider or a raycast that shoots from the Agents downwards. This helps you to check if the Agent is grounded but in terms of a Raycast you will get back RaycastHit struct with all the info about the object that you have detected - in this case it would be the surface.
If you take a look at the RaycastHit documentation Unity - Scripting API: RaycastHit you will find that it have a Vector3 normal which is just a vector coming out of the surface mesh upwards and generally gives you the perpendicular direction “up” (I am fairly sure that you can get similar info rom a trigger collider).
You can rotate / align your Agents transform to have its transform.up match the normal of the surface which should make your Agent always perpendicular to the surface.
I think that you can use Quaternion.FromToRotation to find the correct rotation.
You can check out this thread to learn more Character align to surface normal ???
I hope it helps!
Thank you for your help!