How do I Handle multiple spawner locations

Get help using Construct 2

Post » Thu Apr 07, 2016 11:16 pm

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

Image

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?
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Thu Apr 07, 2016 11:24 pm

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 -
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.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Thu Apr 07, 2016 11:46 pm

oosyrag wrote: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 -
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
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Fri Apr 08, 2016 12:53 am

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
B
9
S
4
G
2
Posts: 39
Reputation: 1,805

Post » Fri Apr 08, 2016 1:07 am

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.
Mistakes were made.
B
51
S
25
G
107
Posts: 1,581
Reputation: 60,458

Post » Fri Apr 08, 2016 1:14 am

oosyrag wrote: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
B
9
S
4
G
2
Posts: 39
Reputation: 1,805


Return to How do I....?

Who is online

Users browsing this forum: Fenix18, tarek2 and 55 guests