How do I Spawn a single Instance of an Object

Just started using Construct 2? Post your questions here

Post » Fri May 01, 2015 11:36 am

Hi All

I'm still working on my Mosquito Game and have the following Problem:

When i turn the Light off, i want it to spawn one Mosquito in a certain Timeframe. Now, it seems to work but if i turn on and off the lights quickly a few times and then leave it off, it spawns multiple Objects for some reason that i'm too stupid to yet comprehend...

It would be fantastic, if somebody could take a look at it: https://drive.google.com/file/d/0Bwu0b_ ... sp=sharing

Image

Thanks so much!!
B
16
S
7
G
2
Posts: 111
Reputation: 2,149

Post » Fri May 01, 2015 1:44 pm

Move the "Set MosqOn to 1" action above the "Wait". What is happening is, you are starting multiple spawn events before setting the MosqOn variable. The Wait command does not wait to allow the system to continue processing, just the actions in the current event that are below it in the list. Since you are waiting the given amount of time to set the variable, the game loops through and finds all the variables still match the event trigger. With the "Trigger Once" condition, it will only trigger once while all the conditions remain true but once you turn the light on and off, the condition is reset.

I hope that answers your question and good luck with your project.
B
39
S
12
G
11
Posts: 331
Reputation: 7,727

Post » Fri May 01, 2015 8:36 pm

Thanks a ton @FragFather !

Now it works like a charm :) It's funny, i seem to have the right ideas but whenever there's a bug i often times just have the orders wrong... I hope i'll get my head around that someday...
B
16
S
7
G
2
Posts: 111
Reputation: 2,149


Return to Beginner's Questions

Who is online

Users browsing this forum: No registered users and 3 guests