Advertisement
evelynshilosky

FollowPlayer - Part 40

Apr 26th, 2024
42
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.40 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FollowPlayer : MonoBehaviour
  6. {
  7.     public Transform player;
  8.     public Vector3 offset;
  9.  
  10.     private void LateUpdate()
  11.     {
  12.         if (player != null)
  13.         {
  14.             Vector3 targetPosition = player.position + offset;
  15.  
  16.             transform.position = targetPosition;
  17.         }
  18.     }
  19. }
  20.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement