Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[SOLVED] How to know if player is in jumping or falling state?
Abion47 Offline
Senior Member

Posts: 369
Threads: 22
Joined: Oct 2015
Reputation: 46
#2
RE: How to know if player is in jumping or falling state?

There is no pre-built IsPlayerJumping or IsPlayerFalling function that I'm aware of, but there are a couple ways to get the same effect.

First, you could check the player's character body's velocity. If the vertical velocity is greater than zero, then they are ascending (jumping) and if it's less than zero, then they are descending (falling):

cVector3f velocity = cLux_GetPlayer().GetCharacterBody().GetForceVelocity();
bool isJumping = (velocity.y != 0);

Second, you can check if the character body's feet are on the ground. If not, then they are in the air as a result of either jumping or falling:

bool isJumping = !(cLux_GetPlayer().GetCharacterBody().IsOnGround());

The first method can throw false positives if the player is ascending or descending for other reasons (such as climbing a ladder or walking down stairs) and the second method doesn't tell you whether the player is rising or falling on its own, so you can get all the information if you combine the two.

01-26-2017, 10:04 PM
Find


Messages In This Thread
RE: How to know if player is in jumping or falling state? - by Abion47 - 01-26-2017, 10:04 PM



Users browsing this thread: 1 Guest(s)