Advertisement
UnityCoder_Jay

FollowObject.cs

Jan 5th, 2023 (edited)
892
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.45 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class FollowObject : MonoBehaviour {
  4.     public Transform Object;
  5.     public float _Smoothing = 1f;
  6.  
  7.     public void LateUpdate() {
  8.         if (transform.position != Object.position) {
  9.             Vector3 ObjectPositon = new Vector3(Object.position.x, Object.position.y, transform.position.z);
  10.             transform.position = Vector3.Lerp(transform.position, ObjectPositon, _Smoothing);            
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement