[Solved] How do I make pin behavior trigger correctly

Get help using Construct 2

Post » Mon Jun 08, 2015 1:03 pm

Greetings everyone :shock:

I got a pin behavior which initially was in the same block where I created the sprites. Now I wanted to organize my project better so I created some "On Created" events in which I added the pin behavior too. This did not work. I do not understand why it did not pick the correct instance to pin the sprite to.

I've attached a capx showing my problem.

Is this a bug of the game engine? Am I not fully understanding how On Created event works?

Please take a look and tell me if you can spare 5 minutes. In the event sheet you will find 2 comments telling you how to replicate the bug.

Image
Image


Download capx: http://www.jefawk.com/games/PinProblem/PinProblem.zip

Thanks for your time
Last edited by Je Fawk on Mon Jun 08, 2015 3:48 pm, edited 1 time in total.
Black Bobby The Hole RPG game Greenlit with 303 votes.
B
38
S
9
G
1
Posts: 174
Reputation: 3,233

Post » Mon Jun 08, 2015 1:29 pm

Adding a wait 0 seconds action before pinning makes it work..
(That way the pinning action will be performed after all other events in the sheet are)
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 08, 2015 2:36 pm

Thank you very much @LittleStain !

If the event sheet would be more complex, would the wait need actually more time? Like wait 0.5 seconds?

I still don't understand why without the wait it doesn't work. The way I see it is that the object is getting created, then the engine jumps to the on created event which pins it. I really don't see how the engine doesn't do what it looks to be something really simple and basic.
Black Bobby The Hole RPG game Greenlit with 303 votes.
B
38
S
9
G
1
Posts: 174
Reputation: 3,233

Post » Mon Jun 08, 2015 3:28 pm

It seems you aren't able to reference sprite_02 and/or sprite_01 at that specific time..
Wait 0 makes sure this action will be executed after all actions (in this specific tick) and as such after the create action, which makes the referencing of the sprites possible..
wait 0.5 will therefore never be needed..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Mon Jun 08, 2015 3:47 pm

Thank you for the details :)
Black Bobby The Hole RPG game Greenlit with 303 votes.
B
38
S
9
G
1
Posts: 174
Reputation: 3,233


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 21 guests