帶剛體的物體在發生碰撞時候的抖動,可以查看如下原因:
一、是剛體物體可能與其他碰撞體有持續的接觸,剛體在接觸面上移動,比如說剛體在一個帶有boxcolider的地面上移動,這個時候你就會發現有些地方會導致剛體位置的變化,應為boxcolider有一定厚度,你人物的colider可能會由於重力等原因進入這個碰撞體,從而導致碰撞體擠壓。
二、 查看人物自己的子物體下面是不是還有其他的剛體
三、移動的代碼要放在fixedUpdate里面,而不是Update。
四、攝像機的跟隨代碼要放在LateUpdate里面,而不是Update。
void FixedUpdate()
{
Move();
}
void LateUpdate()
{
transform.position = playerTransform.position + offset;
if (Input.GetMouseButton(1))
{
rotationY = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityHor;
_rotationX -= Input.GetAxis("Mouse Y") * sensitivityVert;
_rotationX = Mathf.Clamp(_rotationX, minimumVert, maximumVert);
transform.localEulerAngles = new Vector3(_rotationX, rotationY, 0);
}
}
原文鏈接:https://blog.csdn.net/www1501766557/article/details/90755411