# Unity 3D rotationThisFrame parameter(疑問已解決) 在 public void RotationApply(float rotationThisFrame)中 (float rotationThisFrame)是一個參數,表示這個方法需要一個float值才能執行。 當我們呼叫RotationApply時, 調用方法內的float值會被存處在float rotationThisFrame。 也就是rotationThisFrame = RotationSpeed || rotationThisFrame = -RotationSpeed 而根據按下不同的鍵,會回傳不同的值,就可以完成按下不同鍵往不同方向旋轉。 ```C#= void ProcessRotation() { if (Input.GetKey(KeyCode.A)) { RotationApply(RotationSpeed); } else if (Input.GetKey(KeyCode.D))//Left跟right不同時進行 { RotationApply(-RotationSpeed); } } public void RotationApply(float rotationThisFrame) { transform.Rotate(Vector3.forward * rotationThisFrame * Time.deltaTime); } ``` ###### tags: `unity`
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up