标签:oid int log 碰撞 角色 ota nbsp poi code
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); } }
【Unity笔记】将角色的碰撞体朝向鼠标点击方向——角色朝向鼠标
标签:oid int log 碰撞 角色 ota nbsp poi code
原文地址:http://www.cnblogs.com/guxin/p/unity-player-rotate-to-mouse-click-position.html