using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerControler : MonoBehaviour
{
void Start()
{
}
void Update()
{
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hitInfo;
if (Physics.Raycast(camRay, out hitInfo))
{
Vector3 target = hitInfo.point;
//下面这句确保了鼠标指到角色身上不乱跳
target.y = transform.position.y;
transform.LookAt(target);
}
}
}
角色跟随鼠标位置旋转
最新推荐文章于 2022-08-05 14:31:56 发布