Rotate player towards the floor

Hey guys! I need a script that will rotate the player towards the floor angle. I have been googling a lot, but I could not find anything I could use.

Ok, so what I need to do is rotate the player from




The red arrows are indicating the direction the player will move.

Is there any way to do this?

– David

Try raycasting down, then reading the ‘normal’ of the floor. Then rotate the player to match the ‘normal’ s rotation to the floor. I had the same problem , but luckily Aldo Naletto provided the solution.

My question :

Aldo’s other post (with illustrations from the question’s asker similar to yours) :

So you have both js and C# versions, hope this helps a little =]

yes there is and its quite simple just get the floors rotation and make the cube as it rotation like so (Javascript)
<pre> var Cube : Transform; var Floor : Transform; function Update() { Cube.rotation = Floor.rotation; } </pre>
drag (in editor) the objects into their designated spots