How do I Handle multiple spawner locations

0 favourites
  • 6 posts
From the Asset Store
Be quick and choose the right answer for the shown equation.
  • So I have 8 spawner objects (MoneySpawner) and I want each to spawn a coin ONCE randomly.

    Once the spawner has spawned the coin I want that spawner to become deactivated until the coin is removed

    The way I have it set up now is like this

    However Watching in debug mode It will frequently pick a spawner that has money on it. It will not spawn extra money but it will cause a delay in my spawns. So It can take upwards of 10 seconds to get some of these to spawn

    How can I force it to pick an instance that doesnt have money on it?

  • Before your current system condition that picks a random Moneyspawner, you need an additional condition that first picks all Moneyspawners that do not have money on them. Use the condition from the Moneyspawner object rather than the system compare two values to check the instance variable. This way, the system pick random Moneyspawner will only pick from the already picked empty Moneyspawners.

    Actually I'm not sure if it will work in the same event, you might need another subevent between the every 2 seconds and pick random events.

    Edit: You dont need another subevent. From the manual - [quote:3fxyz5wv]Pick random instance

    Pick a random instance from the currently picked objects. In other words, if Pick random instance follows another condition, it will pick a random instance from the instances meeting the prior condition. Otherwise it picks a random instance from all the instances.

    So order matters here. Make sure you put the Moneyspawners Is Empty condition before the system pick condition.

  • Before your current system condition that picks a random Moneyspawner, you need an additional condition that first picks all Moneyspawners that do not have money on them. Use the condition from the Moneyspawner object rather than the system compare two values to check the instance variable. This way, the system pick random Moneyspawner will only pick from the already picked empty Moneyspawners.

    Actually I'm not sure if it will work in the same event, you might need another subevent between the every 2 seconds and pick random events.

    Edit: You dont need another subevent. From the manual - [quote:3fmknbgp]Pick random instance

    Pick a random instance from the currently picked objects. In other words, if Pick random instance follows another condition, it will pick a random instance from the instances meeting the prior condition. Otherwise it picks a random instance from all the instances.

    So order matters here. Make sure you put the Moneyspawners Is Empty condition before the system pick condition.

    Works perfect thanks for the help

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Okay next part is when I walk over the money with my player I want the money to despawn and the spawner to become active again.

    I have it set to destroy money add 100 to score and set moneyspawner.moneyspawned to 0

    But what that does is allows every single money spawner to spawn another money

    Which perplexes me because moneyspawned is an instance variable it should only affect the one he touched

  • If you don't have the spawner in the conditions, any action will apply to all the spawners. I'm guessing you only have on collision with coin in your event. Try adding a system pick nearest condition.

  • If you don't have the spawner in the conditions, any action will apply to all the spawners. I'm guessing you only have on collision with coin in your event. Try adding a system pick nearest condition.

    Perfect once again thank you =D

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