您当前的位置: 首页 >  unity

云小川

暂无认证

  • 6浏览

    0关注

    78博文

    0收益

  • 0浏览

    0点赞

    0打赏

    0留言

私信
关注
热门博文

unity Lookat

云小川 发布时间:2022-03-11 13:13:08 ,浏览量:6


using ET;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LookatPlayer : MonoBehaviour
{
    CameraComponent cameraCom;
    void Awake()
    {
        cameraCom = Game.Scene.GetComponent();
        if (cameraCom == null)
        {
            Debug.LogError("û���ҵ�CameraComponent");
            return;
        }
    }

    // Update is called once per frame
    void Update()
    {
        this.transform.LookAt(cameraCom.CurrCamera.Camera.transform);
       // this.transform.forward = Vector3.forward;
        this.transform.localRotation = Quaternion.Euler(new Vector3(0, this.transform.localRotation.eulerAngles.y, 0));
    }
}

关注
打赏
1663746399
查看更多评论
立即登录/注册

微信扫码登录

0.0349s