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

622-rotatePlayer1.png

to

623-rotatePlayer1.png

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 : http://answers.unity3d.com/questions/230216/why-am-i-getting-a-fruity-effect-from-my-raycast.html

Aldo’s other post (with illustrations from the question’s asker similar to yours) : http://answers.unity3d.com/questions/168097/orient-vehicle-to-ground-normal.html

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