key_down时: m_PlayerRb.velocity = Vector2.up * m_JumpForce;//角色向上跳跃
//角色跳起后下落阶段 if (m_PlayerRb.velocity.y<0) { m_PlayerRb.velocity += Vector2.up * Physics2D.gravity.y * jumpFactor*Time.deltaTime;//不停的增加重力,手感更强使游戏更有可玩性 } else if (m_PlayerRb.velocity.y>0&&!Input.GetButton("Jump"))//角色跳起阶段,并放弃按跳跃键 { m_PlayerRb.velocity += Vector2.up * Physics2D.gravity.y * jumpFactor * Time.deltaTime; } }
注意jumpFactor,也就是,下降时,重力加大。 上升时,松开跳跃键,也重力加大。
|