Something I'd like to share about timer behaviour

Discussion and feedback on Construct 2

Post » Fri Apr 24, 2015 4:56 pm

Hi,

So I'm making a "minions" game. My minions would mine. Every time one of them would arrive at the mining place, timer would kicked in, and on timer out, he would go back to the base. But the thing is from time to time, some of them would just "stuck" at mining place, and even with all variables set appropriately, would not move at all. So after whole day of frustration, I switched Timer to Wait action, and everything started working fine. Bug?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 24, 2015 5:04 pm

Might not be that, but you need a for each with the On Timer trigger if multiple instances have this triggering at the same time, not sure why but I remember it.
Game design is all about decomposing the core of your game so it becomes simple instructions.
B
53
S
22
G
18
Posts: 2,122
Reputation: 17,123

Post » Fri Apr 24, 2015 5:11 pm

Aphrodite wrote:Might not be that, but you need a for each with the On Timer trigger if multiple instances have this triggering at the same time, not sure why but I remember it.


That's exactly how I had it set up. I had it Outside For Each, then inside For Each ( this one didn't work at all). Just gaved up.
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 24, 2015 5:59 pm

It might be actually a bug in Timer behavior. Few days ago i had similar situation, where each instance of same object had a different value set in Timer behavior.
And usually when On Timer triggers other instances (with it's own Timer still running) started to do some strange things - things they not supposed to do :D. And also For Each did not helped at all. After removing a Timer and making the same behavior using normal instance variable fixed everything up.
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,597
Reputation: 34,821

Post » Fri Apr 24, 2015 6:24 pm

use
Code: Select all
foreach  object
object is on screen              - do something
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 624
Reputation: 9,421

Post » Fri Apr 24, 2015 6:31 pm

shinkan wrote:It might be actually a bug in Timer behavior. Few days ago i had similar situation, where each instance of same object had a different value set in Timer behavior.
And usually when On Timer triggers other instances (with it's own Timer still running) started to do some strange things - things they not supposed to do :D. And also For Each did not helped at all. After removing a Timer and making the same behavior using normal instance variable fixed everything up.


Now I'm thinking that maybe even Wait action is more imprecise then ever. But I'm tiered, so might be just imagining that without seeing the game. But could you tell me how you did the timer? I'm pretty sure I used to do those in the past, before such thing as timer was a reality, but I can't remember XD

@saiyadjin Not sure how this would suppose to help, but thanks anyway! ;)
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 24, 2015 6:51 pm

saiyadjin wrote:use
Code: Select all
foreach  object
object is on screen              - do something



Yes, That is indeed "for each" condition. Thanks!

@megatronx

Nothing fancy really.

-On star of layout
--for each sprite -> set Timer "xxx" to int(random(5)

-On timer "xxx" -> set Timer "xxx" to int(random(5) and do something with sprite.

With all possible combinations with for each xD
ImageImageImageImage
B
157
S
66
G
41
Posts: 2,597
Reputation: 34,821

Post » Fri Apr 24, 2015 6:56 pm

@megatronx
Maybe post a small example of what you are doing so people can have a look.
ImageImageImage
B
71
S
21
G
229
Posts: 3,686
Reputation: 128,336

Post » Fri Apr 24, 2015 7:00 pm

shinkan wrote:
saiyadjin wrote:use
Code: Select all
foreach  object
object is on screen              - do something



Yes, That is indeed "for each" condition. Thanks!

@megatronx

Nothing fancy really.

-On star of layout
--for each sprite -> set Timer "xxx" to int(random(5)

-On timer "xxx" -> set Timer "xxx" to int(random(5) and do something with sprite.

With all possible combinations with for each xD


Cool. I thought you went with something like this:

Object with varTimerTime set to N, and boolean Timer

For Each
-Is Timer
-Every 1 sec remove 1 from varTimerTime
---TimerTime less or equal 0 : do stuff

Ha! thanks for reminding me :D
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
89
S
29
G
22
Posts: 1,984
Reputation: 19,997

Post » Fri Apr 24, 2015 7:10 pm

If you have to use "for each" then that is a bug.
I suspect this may be something else however.
Possibly how the tags are set up.
It may be possible that an instance may be created after a tag is created, which could cause an issue.
Image ImageImage
B
168
S
50
G
169
Posts: 8,280
Reputation: 108,189

Next

Return to Construct 2 General

Who is online

Users browsing this forum: No registered users and 12 guests