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 关注
- 99 浏览
添加回答
举报