0 Favourites

Make a Instance Variable trigger once

  • hi guys

    im having rpoblems figuring this one out

    how can make an event where a condition is triggered once for every instance, using instance variables as conditions, if i use trigger once it will trigger only once for one of the instances... so it does not work

    i have tried many methods, but i cant figure it out

    this is useful becuase les say that i want to tell a instance, that when its instance varialbe is true to start a timer or something that requires to be triggered once... what do you reccomend??

    you can see what im triying to do in the picture below

    thanks a lot

  • You can use variable like this:

    For each sprite,

    • if instance variable A is 0, set instance variable A to 1 and execute some codes further.

    This will make the code above executed once for each instance when its instance variable is 0. Set instance variable to 0 again somewhere for a particular instance to have the event run this part again for that particular instance.

    Don't use "trigger once". If my memory is correct, it is not applicable in for each loop.

    Actually... can you tell us your big picture? What are you trying to do?

    not sure whether this will help you.

  • Construct 3

    Buy Construct 3

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

    Buy Now Construct 3 users don't see these ads
  • You can use variable like this:

    For each sprite,

    - if instance variable A is 0, set instance variable A to 1 and execute some codes further.

    This will make the code above executed once for each instance when its instance variable is 0. Set instance variable to 0 again somewhere for a particular instance to have the event run this part again for that particular instance.

    Don't use "trigger once". If my memory is correct, it is not applicable in for each loop.

    Actually... can you tell us your big picture? What are you trying to do?

    not sure whether this will help you.

    mmmm what you are saying makes a lot of sense... i will try it and report the results

  • Yikes, I just read my post again. If it's not helpful to you, as in you have hard time interpreting my text, feel free to ask. I will try to tone down my wording and try to put myself into your shoe more.

    But do you understand what I am saying above?

  • im having problems... i still cant figure this out

    i have this enemy that when its hp os = or > to 0 then set dead cariable to 1

    then if dead is = 1 set the death animation

    but if i set it to trigger once, it will trigger the animation only for the first enemy that dies...

    and if i set it without the trigger once it will play the animation every tick... so it wont play :/

    is there some condition or somethign that could solve this problem??

  • I'm 90% sure I read recently that Trigger Once doesn't work with instance variables. How about setting Dead=2 when Dead=1 is processed.

    Edit: add Dead=0 to your HP<=0 test

    Edit: or just HP<=0 & Dead=0 ->Dead=1, Set animation...

  • I'm 90% sure I read recently that Trigger Once doesn't work with instance variables. How about setting Dead=2 when Dead=1 is processed.

    Edit: add Dead=0 to your HP<=0 test

    Edit: or just HP<=0 & Dead=0 ->Dead=1, Set animation...

    yeah, that seems to work, but i see it as a very bad solution, since having to change the variable jsut to make a trigger once... seems very cumbersome, i think ashley should add a condition like that replaces this method

    thanks to both of you guys =)

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