trigger once and instances

Get help using Construct 2

Post » Sun Feb 16, 2014 4:54 pm

@Lucid as well :)
hi to the community !i need your help.
for the past 2 days i am trying to figure out what is going on until i stumbled on this thread.http://www.scirra.com/forum/r154-for-each-and-trigger-Once_topic82932.html
i have for example 3 instances of a scml animation(spriter).it is in a container with a sprite box background and i run it every tick on top of it.
i have a LOS (line of sight ) behavior on my sprite box
if "sprite box" has LOS on player----set scml animation to "walk"
if "sprite box" has NOT LOS on player----set scml animation to "IDLE"
if i use this, then the animation gets stuck on the first frame (no tweening no nothing)because i think it runs every tick so it resets 60 times per second and plays from the beginning all the time .
if i add a sub-event "trigger once while true" it works(the animation) up to the moment it switches between LOS and NOT LOS and the reason is in what Ashley said that it is a system condition(the "trigger once") and does not pick instances!so only one instance switches between idle and walk and the rest stay on the previously played animation (wish i knew that 2 days ago :p) maybe i could use uid but that would be a pain to implement if i have 20 instances of my scml in every layout.
so any ideas on what to do to solve this?
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Feb 16, 2014 4:59 pm

And if you add the condition "animation walking is not playing"?
B
10
S
2
Posts: 135
Reputation: 1,090

Post » Sun Feb 16, 2014 5:08 pm

why not use an else condition instead of the has not los?

or am I missing the point?
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 » Sun Feb 16, 2014 5:14 pm

@Alyra Games
i lost you there for a moment but thank you for your interest to help me.
the problem is that for conventional animations (png's) using the platform behavior ashley has programmed conditions that trigger animations (on landed,on stopped etc).
in my case the system correctly picks every instance change(los ,NOT los) -it is built in ,you don't even have to say "for every"-,every instance variable change everything.
it even changes the animation as intended but to ONLY ONE INSTANCE at a time. the rest are ignored.
i hope i was more clear this time
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Feb 16, 2014 5:23 pm

@LittleStain
if i use "else" the it does not pick .it just makes them all behave the same.
my problem lies in the fact that if i do not use "trigger once while true"
then my animation loops every tick so it gets stuck on the first frame.if i use it it plays fine BUT it does not pick instances so it only triggers for the first instance and the rest of them still play the old animation.
example. 3 spiders with LOS 600pixels
if the see you (<600) play "walk" if not (>600) play "idle"
they cant see you at first so the are all "idle"
you move closer and all of them see you. only one will play "walk" (using the "trigger once")the other will stay "idle"
now if you move away only one will play"idle" the rest will stay on animation "walk"
see my problem? :)
Roccinio2014-02-16 17:32:39
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Feb 16, 2014 5:31 pm

Shouldn't they only play the walk animation while walking?
So wouldn't it be easier to start moving on los and set animation walk when moving?

I'm under the impression the problem is not where you think it is. This sounds more like a conflicting event issue. Are you setting the animations anywhere else in your event sheet too and are the conditions for that event true aswell?
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 » Sun Feb 16, 2014 5:42 pm

@LittleStain
thank you for your time!
if i use "else" the it does not pick .it just makes them all behave the same.
i have a sprite box with path finding behavior that i set invisible and i add "every tick" on top of it my scml(spriter) animation.so the box moves.the "animation"(spider) just moves on top of it and it just changes its animation depending if the "box" is moving or not.since they are in a container every time i spawn a "box" it spawn a spider"animation" on top of it.so if any of the "boxes" has LOS to the player then enable "pathfinding" and move. so play "walk" animation for spider.
if not "set pathfinding disabled" so it stops and play "spider" animation "idle".
my problem is that because the "has los" or "does not have los" runs every tick when it is true the animation will loop every tick so it will get stuck on the first frame(it is not frame it is tweening but you get the picture :p).
if i add a "trigger once while true" it will run fine the animation because it will not loop every tick BUT this command does not pick instance so it will only work on the first available instance. not the rest.


B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Sun Feb 16, 2014 5:52 pm

Would something like this work?

for each box
box has line of sight
box is not moving along path
- find path

For each box
on path found
- move along path
- set animation to walk
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 » Sun Feb 16, 2014 6:16 pm


@Asley
@Lucid
@LittleStain
unfortunately no my friend.
my results so far .
if i use the build in commands for my scml files (on landed,on moved etc)
it works in all instances correctly.
if i want to trigger an animation without the above i need to apply the "trigger once while true" so it will not get stuck on the first frame. this workaround works for only one instance perfectly. i can call any animation i want depending on the situation.
but if i have multiple instances then the "trigger once" does not pick instances and it works only for the first it picks.
any ideas from the other gurus in here?
mr. Asley please?
B
15
S
6
G
4
Posts: 277
Reputation: 3,948

Post » Tue Feb 18, 2014 2:32 am

You need to add an instance variable to the entity you change the animation on

In sight> Do stuff + set variable to 1
Not In sight + Variable=1 > Do stuff, set variable to 0

This makes it when they are not in sight, that it checks for that variable, and if that variable is 1 (because it was set when they were in sight), then it does stuff and sets the variable to 0

Since the variable is 0 for that entity next tick, it does not trigger the not in sight actions again. This makes it so it leaves whatever you had set, set.


This is essentially how the Trigger Once condition works, except you're coding it in-engine for specific entities.
B
21
S
8
G
6
Posts: 346
Reputation: 4,891

Next

Return to How do I....?

Who is online

Users browsing this forum: Google [Bot] and 34 guests