Make a Instance Variable trigger once

Get help using Construct 2

Post » Fri Apr 25, 2014 6:14 am

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 do not have the required permissions to view the files attached to this post.
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Fri Apr 25, 2014 7:09 am

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.
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Fri Apr 25, 2014 11:59 am

keroberos wrote: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 :), thanks a lot :D
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Fri Apr 25, 2014 1:55 pm

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?
I got a game that you multiply, breath fire with two heads and brawl foes to oblivion with your clones: http://www.newgrounds.com/portal/view/660664 (use Chrome on Windows for best performance)

My sites:
http://twinblazar.deviantart.com
http://twinblazar.newgrounds.com
https://twitter.com/twinblazar
http://www.pixiv.net/member.php?id=15072448
B
30
S
11
G
11
Posts: 411
Reputation: 8,469

Post » Mon Apr 28, 2014 9:08 pm

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??
You do not have the required permissions to view the files attached to this post.
B
23
S
6
G
3
Posts: 316
Reputation: 3,461

Post » Mon Apr 28, 2014 9:35 pm

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...
ImageImageImage
B
71
S
21
G
233
Posts: 3,696
Reputation: 130,368

Post » Wed Apr 30, 2014 6:43 pm

blackhornet wrote: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 =)
B
23
S
6
G
3
Posts: 316
Reputation: 3,461


Return to How do I....?

Who is online

Users browsing this forum: Baidu [Spider], Yahoo [Bot], yiuyiu6666 and 14 guests