28 lines
675 B
C#
28 lines
675 B
C#
|
using UnityEngine;
|
||
|
|
||
|
public class CameraMove : MonoBehaviour
|
||
|
{
|
||
|
public Vector3 camOffset;
|
||
|
|
||
|
[SerializeField] private GameObject player;
|
||
|
|
||
|
// Start is called once before the first execution of Update after the MonoBehaviour is created
|
||
|
void Start()
|
||
|
{
|
||
|
|
||
|
}
|
||
|
|
||
|
// Update is called once per frame
|
||
|
void LateUpdate()
|
||
|
{
|
||
|
camOffset.z = camOffset.x;
|
||
|
Vector3 desiredCamPos = player.transform.position;
|
||
|
desiredCamPos.x += camOffset.x;
|
||
|
desiredCamPos.y += camOffset.y;
|
||
|
desiredCamPos.z += camOffset.z;
|
||
|
|
||
|
transform.position = desiredCamPos;
|
||
|
transform.LookAt(player.transform);
|
||
|
}
|
||
|
}
|