How could I make a variable with how long I stay in the air?

Hi, same as in the title!
How could I make a variable (float) with how long I stay in the air??
A variable that will show me each frame. If that is possible:)

Do you want the result to be in seconds, or show the number of frames?

Seconds

You can create a variable to store the time that the player stays in the air by using a custom C++ function or a Blueprint.

Here is how you can do it using Blueprints:

  1. Create a new Blueprint class and make it a child of the player pawn class.
  2. In the new Blueprint class, add a new float variable to store the time in the air.
  3. In the Event Graph, add a custom event node, such as “Event Tick”.
  4. In the custom event node, check if the player is in the air (e.g. by checking the velocity or location of the player).
  5. If the player is in the air, add the delta time (time since last frame) to the variable storing the time in the air.
  6. If the player is no longer in the air, reset the variable to 0.
  7. Use the variable in other parts of your game as needed.
1 Like

Something like that?

if so… it doesn’t show me properly :frowning:
Screenshot_2

I want it to be something like this, if I stay 0.5 seconds in the air, the result should be 0.5 in the float variable.

Hmm, actually it might be easier with a timer in that case. Sorry, but I suggest looking at this instead: Using Timers | Unreal Engine Documentation

It would be more beneficial than constantly running this function on a Tick.

1 Like