How do I stop enemy spawning when my player is dead?

0 favourites
  • 3 posts
From the Asset Store
Basic Rounded Vector Geometry Player Design with Glow for 3 player games
  • Hello, I've created a Space Shooter typed of game, Also I am a beginner, I don't know how to stop an event or "Create Object" Action, well I simply got a solution, the Image below is my solution.

    imgur.com/HANv3rX

    imgur.com/WZCsSzd

    And here is the full code

    imgur.com/knldQqv

    imgur.com/Y1bU5dl

    And I've added my player an Instance variable called "player_IsAlive" with the Initial value of 1

    So the first image stated, if player_IsAlive = 1 then Every 1 Second Create an Object (Enemy) or else if player_IsAlive is equal to or less than 0 then (inverted code) Every 1 second do not Create an Object (Enemy) (As this is I red after the else if)

    And the health event, there are some basic actions where set animation action and destroy action is, after the destroy action I then put the action to set the value of player_IsAlive to 0.

    I don't know if this is the correct code as I red after the else if in the first image, If I am somehow wrong please respond.

  • Simply delete your events 4,5 and 6.

    Only if player is alive, new enemy will be spawned.

    That's it. You don't need the code "If not alive, then don't spawn enemies".

    You can add "Player Set player_IsAlive=0" to event #11, although this is not necessary. After player object is destroyed, event #2 will stop working anyway.

    One more thing - when you invert an event, you invert the condition (left part), not the action (right part).

    So your event #6 means:

    Condition -> "NOT every 1 second"

    Action -> "Create new enemy".

    As a result new enemy will be created not on every 1 second, but on every tick, about 60 times per second.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Thanks

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)