duck

duck

May 7th, 2010
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.32 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class LookAtTarget : MonoBehaviour
  4. {
  5.     public Transform target;
  6.  
  7.     void Update()
  8.     {
  9.         Quaternion targetRot = Quaternion.LookRotation(target.position - transform.position);
  10.         transform.rotation = Quaternion.Slerp(transform.rotation, targetRot, 2f * Time.deltaTime);
  11.     }
  12. }
Advertisement
Add Comment
Please, Sign In to add comment