目前我有一艘飛船圍繞着一顆行星飛行。它看起來像這樣團結 - 向左或向右傾斜飛船
,我使用此代碼
public class PlayerMovement : MonoBehaviour
{
private float currentMovementSpeed = 30;
private float rotationSpeed = 80;
private Rigidbody rigid;
private void Start()
{
rigid = GetComponent<Rigidbody>();
}
private void Update()
{
// move the spaceship
rigid.MovePosition(rigid.position + transform.TransformDirection(new Vector3(0, 0, 1)) * currentMovementSpeed * Time.deltaTime);
// rotate the shaceship by pressing A or D
transform.Rotate(0, Input.GetAxis(StringCollection.INPUT_HORIZONTAL) * rotationSpeed * Time.deltaTime, 0);
}
}
所以,當我按。我想船上小費向左
,並按時DI要將小船運送到右側
有人知道該怎麼做嗎?
您可以檢查如果A或D關閉,請更新,然後應用您的旋轉功能。 – Universus
您是否可以接受我的答案,以防萬一您正在尋找。如果您需要更多關於如何解決問題的信息,請告訴我,我會用更長的解釋完成 –