int floorMask; // 自动寻路层
void Awake()
{
    floorMask = LayerMask.NameToLayer("Floor");
}
void Turning() { Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit floorHit; if (Physics.Raycast(camRay, out floorHit, floorMask)) { Vector3 playerToMouse = floorHit.point - transform.position; playerToMouse.y = 0; Quaternion newRotation = Quaternion.LookRotation(playerToMouse); playerRigidbody.MoveRotation(newRotation); } }

 

相关文章:

  • 2021-09-18
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2022-12-23
相关资源
相似解决方案