"Trigger Once" Question

0 favourites
  • 7 posts
  • 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:

    <img src="http://i216.photobucket.com/albums/cc212/darkstorne/RunSpeed_zps94b283ed.jpg" border="0" />

    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 <img src="smileys/smiley12.gif" border="0" align="middle" />

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

  • 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 <img src="smileys/smiley17.gif" border="0" align="middle" />

    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.

  • Try Construct 3

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

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

  • Hey, that's great! Thanks <img src="smileys/smiley1.gif" border="0" align="middle" /> 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?

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

  • 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 <img src="smileys/smiley1.gif" border="0" align="middle" />

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