Unity Recipes - Look Toward Direction of Velocity
Posted on Aug 29, 2018 (last modified May 7, 2021)
The following C# script for Unity can be used to make an object look toward the direction of its current velocity.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MyController : MonoBehaviour {
     
    private void Update() {
        lookTowardDirectionOfVelocity();
    }
    
    void lookTowardDirectionOfVelocity() {
        transform.rotation = Quaternion.LookRotation(player.GetComponent().velocity);
    }
}