"Trigger Once" Question

Get help using Construct 2

Post » Thu Apr 25, 2013 5:56 pm

Hello! I'm trying to use the Trigger Once While True condition to "gate" other events, hopefully cutting down on the number of events being checked every frame. Here's how I have a little section set up:



I have three base animations - Running, Jumping, and Rolling. The character's movement speed stat can change, so I have that stored in a variable. But as his movement speed increases, I want his run animation to speed up at the same time, which is what I'm trying to accomplish here. However, while this section works perfectly the first time it's triggered, when the player jumps (switching animations) and then eventually goes back to the run animation, it reverts back to the base animation speed, and this event doesn't trigger again.

I was hoping the change in animation would allow the "Trigger Once" condition to be reset, but it doesn't seem to. Disabling or removing the "Trigger Once" condition works perfectly well, and without any slowdown, so this isn't a big issue. I was just hoping to cut down on events per tick.

Should "Trigger Once While True" be working how I expect it to? Or am I just using it for a situation it was never intended for?

Thanks for reading
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Thu Apr 25, 2013 6:14 pm

Are you resuming or starting the run animation again from beginning?

Also is the speed ever dropping below these sectioned speeds?

would it not be better to always have the speed of animation set to your speed variable, it would just need the variable tweaking a little

Ie

>player is on screen ...set animation speed to variable speed

this would speed up all animations to make him appear swifter in all movements.
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Thu Apr 25, 2013 6:53 pm

Well, the movement speed is defined by Construct, so even though my slowest speed for the player is 300, that would be an insane animation speed

The base speed for movement is 300. You can improve that with items, up to a max speed of 600. So I wanted to create an event that basically works like this:

Is the "Running" animation playing? If yes, check the "Speed" variable and adjust animation speed as necessary. Only do this once for each time the "Running" animation plays.

Since it works fine without "Trigger Once", I'm assuming that it can't distinguish between when animations change. Which is a shame. Nothing huge though, since it's only trying to cut down from 6 event checks per tick to 1.
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Thu Apr 25, 2013 9:23 pm

Yes it would be insane speed lol, but you could divide it by 12 this would give you an incremental and gradual speed increase/decrease.

350 / 12 = 29.1

450 / 12 = 37.5

600 / 12 = 50

not a million miles from your numbers...

Regarding optimizing the code in that way, I very much doubt it would make any difference...

Pixel perfick2013-04-25 21:27:48
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Thu Apr 25, 2013 9:31 pm

Hey, that's great! Thanks I still only want this to affect the running animation, since the other two would look too fast if they were sped up. But I'm guessing having a single event like this repeating every frame:

If Animation "Running" is Playing   --->   Set Animation Speed to Hero.Speed/12

wouldn't impact performance any more than including a "Trigger Once" command would do? Since it's only one event?
B
15
S
7
G
7
Posts: 250
Reputation: 5,298

Post » Thu Apr 25, 2013 9:38 pm

Yes you can just set that to when running only.

no matter how you work it it will be checking the speed each tick, if not for your conditions, for the platform behavior itself, it's unavoidable.

If you add a trigger once condition anywhere in your events, it will have to check if that's triggered or not, each tick, to be accurate...
As long as I can move left, right and fire, I'm Happy...
B
42
S
15
G
11
Posts: 655
Reputation: 12,260

Post » Thu Apr 25, 2013 10:28 pm

Thanks, that's what I was thinking. So for one event, a "trigger once" really isn't useful. Only if it has sub events.

Thanks for your help Pixel
B
15
S
7
G
7
Posts: 250
Reputation: 5,298


Return to How do I....?

Who is online

Users browsing this forum: blackhornet, makkancs, TiagoCesar and 16 guests