Keeping Object Pointed In Direction Of Travel

I have a rigidbody based object similar to a skier. When traveling down slopes, which is a roadtrack with 90 degree curves with short side ridges to keep the skier on track, the object sometimes begins rotating when bumping another object or the sides. Of course skis should usually point in the direction of travel. I have tried getting previous position and current position and doing a subtraction to get a vector for travel direction but that by itself did not seem to offer enough information to change the eulerAngle.y to get the object pointing in the direction of travel. There as to be an elegant way to do this in a few lines of code…or not.

THX
BTH

transform.position + rigidbody.velocity.normalized will give you a direction vector

i think this will work

var target = transform.position + rigidbody.velocity;
target = target.normalized;
transform.LookAt(target);

rigidbody.velocity.normalized alone will give you the travel direction.

Adding that to transform.position will give you a point a unit/meter in front of the object, and it won’t be a normalized vector anymore.

transform.forward = rigidbody.velocity.normalized;

You will probably also want to enable Freeze Rotations on the rigidbody. It is probably rotating in response to collisions, which will add angular velocity.

Thanks folks. I knew there was a one line code solution.

Best
BTH