How to add trigger once into an 'Or' block

0 favourites
  • 6 posts
From the Asset Store
Change the size and position of everything without calculating anything!
  • This has been bothering me for a long time now. So basically adding trigger once condition into an 'Or' block does not work correctly and it shouldn't since logically the event will be true on the first check & never false again (for the trigger once to reset) therefore no matter what's in the 'Or' block never gets checked (If I am correct, that's just my assumption). Most of the times I go for [inverted condition & inverted condition & inverted condition... & trigger once] rather than [condition or condition or condition... OR trigger once] but that works with fewer conditions, it was about time for me to run into this again with more conditions (20+ animation checks) where I can't simply do the invert checks with a trigger once for obvious reasons. I've uploaded my temporary code smelly solution

    and it's about time again for me to run into more checks where this does not work as well. So my question is: is there a clever & compact workaround for that?

  • It looks like you're trying to do some work the first time a new animation plays. It would probably be easier to call a function whenever you want to change the animation, change the animation in the function, then do some extra work in that function after the animation has been changed.

  • Hey, Ashley! Thanks for responding so quickly! Big fan btw. Here's what I have in a better overview.

    The Function I change the animations in:

    The Functions triggered by/after the animations:

    Yes, I tend not to repeat my code and am using a function(s) and yes, I can just call the functions after the animation changes but since the function in which the animations are changing has it's own SINGLE "functionality" and has nothing to do with the indicators that I want to Destroy & Create (it's functionality is to change animations & aim a given unit according to the aim) - I am trying to get it in a separate place (for indicators only) My problem is really principal and not that much of an issue workingwise because there are a lot of workarounds (I'm seeking for the best one). Since you are an expirienced programmer/developer/engineer... I would like to ask you what would be the best approach to take when I don't want my Aim/AnimationChanger function to know about my Create/Destroy Indicator functions. As well as how to workaround the adding of a Trigger once condition into an 'Or' block.

    I am currently through an OOP course and I tend to apply the learned in my favorite engine where I've spent countless hours making smelly spaghetti structures & bad design. I hope you get what I am trying to explain & ask.

  • *woops*

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • I think you misunderstood. I meant: use functions to change the animation. Then you don't need 'trigger once' to try to figure out when the animation changed; it changes in your function. I didn't mean to call functions in the events with "trigger once".

  • Another thing I forgot to mention is that I call the animation changes every tick because I am rotating the unit as well, functions around the animation changes or at their place (with changing the animation within the function) wouldn't help because yes, they are trigger once but it doesn't matter since they are called every tick. And If I create multiple functions to start animations and call the rest of the functions will still break the thing I'm trying to achieve which is: The Aim/AngleChecker/AnimationChanger thingy calls Destroy/Create Indicators which is what I don't want. I have Indicators group and Attack group, since every family unit is using the Attack group and not only the player (where only the player is using the Indicators and no one else) I want to remove the checks from there not only because it is continuous event and creating instances doesn't like every tick events but as well as because I want to capsulate my code where the Indicators know about their indicators and nothing else, and Unit attack functions know about their units's animation/angle/states and not indicators. This will help me in the long run to capsulate bugs as well - making them easy to catch and easier to fix.

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