1、定义一个全局变量
private bool isPressJumpKey;//是否按了跳跃按钮
2、添加/更改Update()方法
void Update()
{
if (Input.GetButtonDown("Jump"))
{
isPressJumpKey = true;
}
}
3、在Movement()中
void Movement()
{
......
// 跳跃
if (isPressJumpKey && coll.IsTouchingLayers(ground))
{
isPressJumpKey = false;
rb.velocity = new Vector2(rb.velocity.x,jumpforce * Time.fixedDeltaTime);
animate.SetBool("jumping",true);
}
}
原因请移步:https://blog.csdn.net/candycat1992/article/details/22927713第四点让Input能够正确工作
private bool isPressJumpKey;//是否按了跳跃按钮
2、添加/更改Update()方法
void Update()
{
if (Input.GetButtonDown("Jump"))
{
isPressJumpKey = true;
}
}
3、在Movement()中
void Movement()
{
......
// 跳跃
if (isPressJumpKey && coll.IsTouchingLayers(ground))
{
isPressJumpKey = false;
rb.velocity = new Vector2(rb.velocity.x,jumpforce * Time.fixedDeltaTime);
animate.SetBool("jumping",true);
}
}
原因请移步:https://blog.csdn.net/candycat1992/article/details/22927713第四点让Input能够正确工作









