How to make a flight mode?

So in my game, the main character is a bat, and i want to make it fly around for a short period of time, let me explain the steps:

step 1: player press space while the bat is falling

step 2: bat open wings and start flying for like 2 seconds, allowing to fly around in 4 directions.

step 3: bat falls again and won’t open wings again until it hits the floor.

hope this help.

1 Like

I would do this, it is necessary:

  • 2 timers: the first one will keep track of how long the character flies, the second - the recharge of the ability (if the recharge is not needed, then the second timer is not needed);
  • if the player has the ability to fly in 4 directions, then Top-Down Movement behavior is required;
  • falling of the character can be realized using the same behavior as the control (just always move down);
  • the number of variables will depend on your implementation (I suppose, at least you may need the IsCanFly variable, which will take into account whether you can fly or not, and the IsFly variable, which will take into account whether the character is flying or not).

cool explanation, but i would like if you elaborate on how to make the character fly

It depends on how you want to implement it. As you wrote that a bat should fly in 4 directions for 2 seconds. How do you imagine the flight itself:

  • moving in 4 directions without gravity, flapping wings - in this case, depending on the pressed flight direction button, you simply move the soap in the desired direction (this can be done using the Top-Down Movement behavior);
  • if you want the flight to be realistic and the player would need to “flap his wings” to maintain the mouse in the air and change the height, then here you need a physics engine and settings for the character, so that when the buttons are pressed, the mouse receives an impulse or force is applied to movement.

Here the decision depends on your idea.