//第一次跳
void Jump()
{
//判断是否在地面,如果是在地面允许跳
if (m_isOnGround)
{
m_rigidbody.drag = 5f;
//bool类型,按space键跳跃,返回bool类型
if (m_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;
}
}
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。