diff options
Diffstat (limited to 'LookAtVelocity.cs')
-rw-r--r-- | LookAtVelocity.cs | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/LookAtVelocity.cs b/LookAtVelocity.cs new file mode 100644 index 0000000..6504d6f --- /dev/null +++ b/LookAtVelocity.cs @@ -0,0 +1,19 @@ +using UnityEngine; + +public class LookAtVelocity : MonoBehaviour +{ + private Rigidbody rig; + + private void Start() + { + rig = GetComponentInParent<Rigidbody>(); + } + + private void Update() + { + if (rig.velocity.magnitude > 2f) + { + base.transform.rotation = Quaternion.LookRotation(rig.velocity); + } + } +} |