Scriptum/Assets/Scripts/CamerFollow.cs

26 lines
608 B
C#
Raw Normal View History

2022-03-24 22:50:10 +01:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CamerFollow : MonoBehaviour
{
private Transform playerTransform;
// Start is called before the first frame update
void Start()
{
playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
}
void LateUpdate()
{
// we store current camera's position here
Vector3 temp = transform.position;
temp.x = playerTransform.position.x;
temp.y = playerTransform.position.y;
transform.position = temp;
}
}