我的腳本是關於我的球何時擊中「陷阱對象」,它將移動到開始位置並在那裏停止。怎麼做?如何停止移動物體
void OnTriggerEnter (Collider other)
{
if (other.gameObject.CompareTag ("Trap"))
{
//move object to start position
transform.position = startposition.transform.position;
// I want to stop the object here, after it was moved to start position. Because my ball was moving when it hit Trap object, so when it was moved to start position, it keeps rolling.
}
}
您將不得不重置當前的力並將其設置爲0。一種方法是將Rigidbody(ball)設置爲.isKinematic = false,並將velocity和angularVelocity設置爲vector3.zero。然後將isKinatic設置爲true。 –