Advertisement
BenTibnam

Incredibly Simple Top Down Camera View Script C# Unity

Dec 8th, 2022 (edited)
679
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.49 KB | Gaming | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class FollowPlayer : MonoBehaviour
  6. {
  7.     [SerializeField] private GameObject player;
  8.    
  9.     private const float CAMERA_Z_POSITION = -10;
  10.     // Update is called once per frame
  11.     void Update()
  12.     {
  13.         float playerX = player.transform.position.x;  
  14.         float playerY = player.transform.position.y;
  15.  
  16.         transform.position = new Vector3(playerX, playerY, CAMERA_Z_POSITION);
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement