0 Favourites

Spawner Help

  • I made some spawners that spawn enemies when they come onto the screen.

    I want to make it so they only spawn if the enemy that they just spawned no longer exists when the spawner comes back onto screen.

    Nothing that i have tried has worked, hoping someone can point me in the right direction.

    example

    https://www.scirra.com/arcade/other-games/spawner-example-5538

    capx

    https://games.scirra.net/games/5538/files/game.capx

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You will need to "bind" the enemy to the spawner.

    Spawner gets a booleon variable called "enemy_in_game"

    The enemy gets a variable called "spawnerUID"

    On create the enemy sets "spawnerUID" to the spawners UID and the spawner sets "enemy in game" to true

    On enemy destroy pick the spawner with the "spawnersUID" and set "enemy in game" to false.

    if "enemy in game" is false and the spawner comes onto screen--->spawn enemy

  • Like this?

    http://i.imgur.com/LPTq4af.png

    Doing that made only one of the spawners work, and it would spawn an enemy as soon as one was destroyed (going off screen).

    I only want the spawners to spawn if they enemy they spawned no longer exists and if the spawner has exited and re-entered the screen.

  • Ok it just needs some tweaking.

    In the first event you dont pick a specific spawner so construct picks all of them.

    So it will set ALL spawners to "enemyingame" true.

    In the destroyed event you just set 1 spawner to "enemyingame" =false.

    Thats why just one works.

    You need to tell the event on which spawner the enemy has spawned.

    The second problem is a bit more tricky.

    You need to tell the spawner that it isent on screen to "reload" it.

    At least thats what i understand you would like to have.

    So i guess you will need another variable calles "readytospawn" or something like that.

    If the spawner spawns "readytospawn" set to false.

    If the spawner is NOT on screen set "readytospawn" to true.

    if "readytospawn" =true and "enemyingame" = false and spawner on screen then spawn new enemy.

  • I figured it out.

    Here's how i did it in case anyone is looking to do something similar.

    http://i.imgur.com/xdLA2fk.png

  • looks like you started replying right as i figured it out. thanks for the help!

  • Looks fine.

    With the counter variable you could even bind more than 1 enemy to a spawner.

    There are some small things that shouldent be necessary like storing the spawnersUID in itself or the double loop but who cares if it works.

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