rotate quaternion along local Y axis

I have a cube that moves along uneven terrain and rotates to be tangent to the ground beneath it. I need it to face the direction it is moving in along the uneven ground while still being tangent to it. I can do this in the unity editor but I am not sure how to do it in script

– video of what I’m trying to do

Just use Quaternion.LookRotation or Transform.LookAt . Set your movement direction as forward and the surface normal as up.

Ok thanks! its working great now!

how do you mark it as resolved? this is my first on

You can edit your original post, and select a different flair (it is Question right now).