我試圖為我的影片制作代碼,我寫了這個:
if (Input.GetKeyDown("w"))
{
animatorz.Play("SlowRun");
Debug.Log("ya");
}
從技術上講,這一切都有效,但是當我按下 W 時,例如,A 在按下 WI 時從 A 松開,它讓我回到空閑狀態,但我仍然按下 W,有沒有辦法讓它像在實際游戲中一樣正確? 謝謝!
uj5u.com熱心網友回復:
歡迎來到堆疊溢位!該腳本將允許影片繼續播放!
if (Input.GetKey(KeyCode.W) || Input.GetKey(KeyCode.A))
{
animatorz.Play("SlowRun");
Debug.Log("ya");
} //This will allow the animation to keep playing.
您只需添加即可添加更多鍵
|| Input.GetKey(KeyCode.YourKey)
像我上面所做的那樣到 if 陳述句。
uj5u.com熱心網友回復:
該GetKeyDown方法只觸發一次。GetKey相反,您想要觸發每一幀: https ://docs.unity3d.com/ScriptReference/Input.GetKey.html
使用它,如果影片已經在播放,您需要檢查回圈,這樣您就不會在播放器按下鍵的每一幀都重新啟動它,GetCurrentAnimatorStateInfo例如使用https://answers.unity.com/questions/362629/how- can-i-check-if-an-animation-is-being-played-or.html
uj5u.com熱心網友回復:
哦,無論如何,這對你們所有人都有很大的幫助,真的很感激,因為被卡住了,我需要通過文憑。
轉載請註明出處,本文鏈接:https://www.uj5u.com/shujuku/438289.html
