123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- //using Vuforia;
- public class FollowHorizontaliCamera : MonoBehaviour
- {
- [SerializeField]
- private float Distance = 1.0f;
- private void LateUpdate()
- {
- if(Input.GetKeyDown(KeyCode.Space))
- {
- RefreshPos();
- }
-
- }
-
- //同步位置
- public void RefreshPos()
- {
- CDebug.Log("RefreshPos");
- if (FollowTarget != null)
- {
- this.transform.position = FollowTarget.position;
- this.transform.eulerAngles = FollowTarget.eulerAngles.y * Vector3.up;
- this.transform.position += this.transform.forward * Distance;
- }
- }
- private Transform FollowTarget
- {
- get
- {
- if (Camera.main != null)
- {
- return Camera.main.transform;
- }
- return null;
- }
- }
- }
|