我正在製作一個統一的3D遊戲,遊戲的一部分允許玩家進入汽車並驅動它。統一遊戲對象不在正確的位置
車內我放置了一個「座位」遊戲對象,其位置和旋轉用於確定玩家將坐在哪裏。
當我想讓玩家坐在車裏時,我讓車成爲父母,然後將玩家轉換位置和旋轉角度設置爲座位。
下面是C#代碼
// make player's parent the same as the seats parent (which is the car)
transform.parent = seat.transform.parent;
// put player in the exact position and rotation as the seat
animator.transform.position = transform.position = seat.transform.position;
animator.transform.rotation = transform.rotation = seat.transform.rotation;
animator.transform.localPosition = transform.localPosition = seat.transform.localPosition;
animator.transform.localRotation = transform.localRotation = seat.transform.localRotation;
這似乎是它應該工作,但什麼最終happenning是,由於某種原因,球員不能很好地在座位上結束,但記者從一些很短的距離它,也是球員輪換不符合座位,而是稍微偏離。所以這名球員看起來好像並不是真的在座位上,而是在靠近它的位置,然後轉向另一個方向。
有人知道我在做什麼錯嗎?