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?
Mafiyia Offline
Junior Member

Posts: 7
Threads: 4
Joined: Jan 2017
Reputation: 0
#1
[SOLVED] How to know if player is in jumping or falling state?

Is there a method that can tell me if the player is in the jumping state? I know there is a Player_Jump() method that makes the player jump, but I'm looking for a method that returns true if the player is jumping and false if not or something that resembles that.
(This post was last modified: 01-26-2017, 10:52 PM by Mafiyia.)
01-26-2017, 09:36 PM
Find Reply
Abion47 Offline
Senior Member

Posts: 351
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 Reply
Mafiyia Offline
Junior Member

Posts: 7
Threads: 4
Joined: Jan 2017
Reputation: 0
#3
RE: How to know if player is in jumping or falling state?

This is exactly what I was looking for. Thanks!
01-26-2017, 10:52 PM
Find Reply


[-]
Quick Reply
Message
Type your reply to this message here.

Human Verification
Please tick the checkbox that you see below. This process is used to prevent automated spam bots.



Users browsing this thread: 1 Guest(s)