spawner on (3/globalvariable) seconds - restart issue

Get help using Construct 2

Post » Fri Apr 14, 2017 11:18 am

I have my project set up to spawn an object every 3/variable seconds, this is so I can increase/decrease/stop the speed of the spawner when a certain events are triggered.

This works fine the first time around but when the layout is reset (go to layout is the same) the spawner doesn't trigger at all. when I remove the /variable then everything works as expected.

I have made sure the variable resets (as I realize dividing by 0 would cause this), and the objects to be spawned are on the layout when it resets.

ps. Thanks for all the help so far, I will pay it forward as I get more knowledgeable.
B
8
Posts: 21
Reputation: 342

Post » Fri Apr 14, 2017 11:33 am

Would be helpful if you could provide a sample capx to demonstrate the problem. This whole trigger business can be quite confusing. :-)
B
42
S
12
G
1
Posts: 76
Reputation: 2,996

Post » Fri Apr 14, 2017 12:12 pm

No problem @faulknermano, I've figured out that the fault lies in letting the variable get to 0, if I reset it to 0.1 or above it then it works fine. But this isn't ideal.

Here's the capx https://www.dropbox.com/s/0sv3geztg3w3x ... .capx?dl=0

You can see the issue by pressing pause before pressing the reset button.
B
8
Posts: 21
Reputation: 342

Post » Sat Apr 15, 2017 12:23 am

@shaundraws, quite an interesting problem. I think because you are using a System condition (for every x seconds) it may not take a 'divide by zero' kindly. Perhaps there is a internal state issue causing the condition to break down once it has reached that.

My suggestion is to use your own timer. I've modified a bit of the capx as an example of how I might approach it.

capx

(Using your own math for randomising using the speedmultiplier variable, I've put the value into a variable called 'interval' which is the time that the ongoing timer needs to reach before spawning. The timer simply increments at delta-time per tick, and then resetting back to 0 when interval is reached)
B
42
S
12
G
1
Posts: 76
Reputation: 2,996


Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 36 guests