当前位置:   article > 正文

unity Lookat_unitylookat

unitylookat
  1. using ET;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. public class LookatPlayer : MonoBehaviour
  6. {
  7. CameraComponent cameraCom;
  8. void Awake()
  9. {
  10. cameraCom = Game.Scene.GetComponent<CameraComponent>();
  11. if (cameraCom == null)
  12. {
  13. Debug.LogError("û���ҵ�CameraComponent");
  14. return;
  15. }
  16. }
  17. // Update is called once per frame
  18. void Update()
  19. {
  20. this.transform.LookAt(cameraCom.CurrCamera.Camera.transform);
  21. // this.transform.forward = Vector3.forward;
  22. this.transform.localRotation = Quaternion.Euler(new Vector3(0, this.transform.localRotation.eulerAngles.y, 0));
  23. }
  24. }

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/羊村懒王/article/detail/134044
推荐阅读
相关标签
  

闽ICP备14008679号