Advertisement
Hazkin

Untitled

Sep 23rd, 2021
1,333
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  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. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement