Files
XMen/Assets/Scripts/FollowCamera.cs
2025-07-10 14:49:53 +08:00

30 lines
885 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FollowCamera : MonoBehaviour
{
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
//Camera camera = Camera.main;
//Transform camT = Camera.main.transform;
//Vector3 viewPos = camT.transform.position + camT.transform.forward * 0f;
//anchor.transform.position = viewPos;
//anchor.transform.forward = camT.transform.forward;
Transform camT = Camera.main.transform;
Vector3 viewPos = camT.transform.position + camT.transform.forward * 0f;
Vector3 cameraForward = new Vector3(camT.forward.x, 0, camT.forward.z);
transform.position = viewPos;
transform.rotation = Quaternion.LookRotation(cameraForward);
}
}