码迷,mamicode.com
首页 > 数据库 > 详细

Rigidbody相关的操作最好放在FixedUpdate中,update中可能会无效果

时间:2016-11-30 02:28:03      阅读:367      评论:0      收藏:0      [点我收藏+]

标签:rto   nio   poi   put   something   ase   direct   new   相关   

void Turning()
{

// Create a ray from the mouse cursor on screen in the direction of the camera.
Ray camRay = Camera.main.ScreenPointToRay(Input.mousePosition);

// Create a RaycastHit variable to store information about what was hit by the ray.
RaycastHit floorHit;

// Perform the raycast and if it hits something on the floor layer...
if (Physics.Raycast(camRay, out floorHit, camRayLength, floorMask))
{

// Create a vector from the player to the point on the floor the raycast from the mouse hit.
Vector3 playerToMouse = floorHit.point - transform.position;

// Ensure the vector is entirely along the floor plane.
playerToMouse.y = 0f;

// Create a quaternion (rotation) based on looking down the vector from the player to the mouse.
Quaternion newRotatation = Quaternion.LookRotation(playerToMouse);

// Set the player‘s rotation to this new rotation.
m_Rigidbody.MoveRotation(newRotatation);

}

Rigidbody相关的操作最好放在FixedUpdate中,update中可能会无效果

标签:rto   nio   poi   put   something   ase   direct   new   相关   

原文地址:http://www.cnblogs.com/alps/p/6115704.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!