[Solved] How do I make pin behavior trigger correctly

  • Greetings everyone

    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.

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

    Thanks for your time

  • 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)

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • 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.

  • 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..

  • Thank you for the details

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)