//第一次跳
void Jump()
{
//判断是否在地面,如果是在地面允许跳
if (m_isOnGround)
{
m_rigidbody.drag = 5f;
//bool类型,按space键跳跃,返回bool类型
if (m_jump)
{
//bool类型,判断跳跃状态
if (is_jump)
{
//跳跃受力
m_rigidbody.drag = 0f;
m_rigidbody.velocity = new Vector3(m_rigidbody.velocity.x, 0f, m_rigidbody.velocity.z);
m_rigidbody.AddForce(new Vector3(0, moveSet.JumpForce, 0), ForceMode.Impulse);
}
//跳起后,跳跃状态为false
is_jump = false;
}
//重置按键
m_jump = false;
}
}
//第二次跳跃
void Jump2()
{
//如果不是在地面
if (!m_isOnGround)
{
//bool类型,按space键跳跃,返回bool类型
if (m_jump)
{
//bool类型,判断跳跃状态
if (!is_jump)
{
m_rigidbody.drag = 0f;
m_rigidbody.velocity = new Vector3(m_rigidbody.velocity.x, 0f, m_rigidbody.velocity.z);
m_rigidbody.AddForce(new Vector3(0, moveSet.JumpForce, 0), ForceMode.Impulse);
}
//跳起后,跳跃状态为false
is_jump = true;
}
//重置按键
m_jump = false;
}
}