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); } }