Hazkin

Untitled

Sep 23rd, 2021
843
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class CameraFollow : MonoBehaviour
  4. {
  5.     public GameObject target;
  6.     public float speed;
  7.    
  8.     private void Update()
  9.     {
  10.         if (target != null)
  11.         {
  12.             transform.position = Vector3.Lerp(transform.position, target.transform.position, Time.deltaTime * speed);
  13.             transform.forward = Vector3.Slerp(transform.forward, target.transform.forward, Time.deltaTime * speed);
  14.         }
  15.     }
  16. }
RAW Paste Data