123456789101112131415161718192021222324252627282930313233343536373839404142 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- public class FollowHorizontaliHead : MonoBehaviour {
- private void Awake()
- {
- DontDestroyOnLoad(this.gameObject);
- }
- private void LateUpdate()
- {
- RefreshPos();
- }
- //同步位置
- private void RefreshPos()
- {
- if (FollowTarget != null)
- {
- this.transform.position = FollowTarget.position;
- this.transform.eulerAngles = FollowTarget.eulerAngles.y * Vector3.up;
- }
- }
- private Transform FollowTarget
- {
- get {
- if (Camera.main != null)
- {
- //return Camera.main.transform;
- }
- if (SvrManager.Instance.head != null)
- {
- return SvrManager.Instance.head.transform;
- }
- return null;
- }
- }
- }
|