how can i check if the player in the air using c++

i want to check if the pleyer in the air or not by uesing c++

if the actor has a UMovementComponent() then it has a method of IsFalling()
it is not exactly 1 to 1 in its name, where it will return true for if the Z component of the Velocity vector is not equal to 0.
so you might still need to do special logic if you care whether they are moving upwards ow downwards.

If you’re using a pawn without a movement component, you’ll want to run a player-shaped trace right below the player and check if it hits.

If you’d like a detailed example, let me know and I can provide one

I tried to use it but I get an error in the character

If you don’t mind

if this is external to the respective Pawn then it would be MyCharacter->GetMovementComponent()->IsFalling()
the GetMovementComponent() returns a UPawnMovementComponent* so you use the arrow operator not the dot operator (unless you are going to store it as a Stack reference, but that generally is not “safe”)

otherwise what is the error you are getting when you hover over the MyCharacter in your IDE, or in the output window about that line?

1 Like

Since this question is left unanswered, and for anyone who may be looking for the answer in the future; it’s very simple.

This is the expression, you can use it inside an if statement and it will return true if the pawn is moving on ground, and false if not (meaning, in air).

PlayerCharacter->GetCharacterMovement()->IsMovingOnGround()