twinStick/twinStickCrawler/Assets/Scripts/Player/CameraMove.cs

28 lines
675 B
C#
Raw Normal View History

2024-12-08 13:40:51 +00:00
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);
}
}