您好,登錄后才能下訂單哦!
//第一次跳
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。