1 回答

TA貢獻1995條經驗 獲得超2個贊
跳躍狀態是等待玩家再次接觸地面。所以如果你使用 GetKeyUp。而是動畫有退出時間,或者動畫沒有正確開始,因為跳躍鍵在播放器仍在播放時上升。所以要解決這個問題很簡單。等待幾秒鐘,然后關閉動畫。
這是代碼:
if (Input.GetKey(KeyCode.Space)){
? ? StartCoroutine(jumping(2f)); //set time delay to 2 seconds before the anim stop
}
private IENumerator jumping(float Time){
anim.SetInterger("Jumping",1);
moveDir.y = 1;
moveDir *= Speed; //your movement speed value
moveDir = transform.TransformDirection(moveDir); //set local value of moveDir to world
yield return new WaitForSeconds(Time); //adjust the delay of your animation to stop
anim.SetInterger("Jumping",0) //Jumping animation stop after time delay
moveDir = new Vector3(0,0,0); //reset the Vector 3 to zero
}
- 1 回答
- 0 關注
- 123 瀏覽
添加回答
舉報