Strange issues with "trigger once" not working as intended

I’m running into an issue with some logic that despite me placing a “Trigger once” function in my code. I am getting a strange property that although my character is behaving as intended. It is subtracting stamina multiple times in a row when it shouldn’t be.

What I expect is I press the dash button once and the character does it’s intended action and subtract stamina ONCE. I have tried everything I can thing of and nothing seems to work. Any advice would be appreciated.

Note: The delay before it subtracts stamina is part a future feature I plan on that allows for perfectly timed dodges to not consume stamina so keep that in mind.

I can’t be sure if this is your problem but…

Since the events are subevents, the trigger once conditions use the conditions of all of the previous event(s). If the status of any of the conditions move from true to false, the trigger once gets removed and it can be triggered again. You might need to move the events to their own line or add different conditions maybe even introduce another state.

For example: if stamania dropped below 10 and then >= 10 it would trigger one of the last 2 subevents again even if the key was never released.

You could also move that first trigger once up so it only applies to the key presses.

I’m already 10 states deep with a character. I really don’t want to add anymore complexities than I have to since I plan on having multiple playable characters. which is going to need their own set of code since there’s no way to have all the characters run on the same lines of code.

Also I tried the suggestion you offered and it didn’t work.

What happens if you remove wait?

Also i am not sure why you even have sub events
Cause you could have OR statement and under it left or right key pressed and that 2 sub events could be part of main event without even using any sub event

Workaround would be to set some var to check if player is dashing or not
Like boolean var where you set it to true when you initiate dash
And to false after dash
Where for dash to even be possible you check in condition if dash var is false

Removing the delay does nothing for the problem. Also I have no idea how to do OR statements in this engine (might help if it works). If that doesn’t work, I guess i’ll have to bite the bullet and add another variable to my already long list of variables per character. Cries in code

The events are actioned because the conditions were previously false and are now all true again.

Unless the “d key is pressed” and the “not a key is pressed” are changing, it has to be the Stamina_Bar value that fluctuates around a value 10 or the character’s jump ability changes.

Is there anywhere in the other events that increases stamina at a decent clip? And if not, are there events that remove and add the character’s jump ability?

I didn’t knew it was posible to state “1/10” seconds…
also, it looks like you could be using an “or” condition because the outcome pressing right/left is the same.
finaly, when you use a “trigger once” is because you want a whole line of events to trigger “only once”.

It’s probably the Jump logic mucking things up if that’s what’s going on. Have it as a mechanic so dashes counted as jumps for gameplay reasons. So most likely I will have to add a variable to fix it. I haven’t even touched some of the core mechanics of my game yet and I’m already 17 variables per character deep. Gonna have to make sure my code is optimized so I don’t make my laptop cry trying to run my game.

Also, yeah, I prefer to write my time in fractional notation in case I have to use weird irrational numbers like 2/3, 4/7, and 5/9 while maintaining numerical accuracy. In otherwords, I hate rounding errors lol

Come to think of it, I think the “Advanced Platformer Movement” Extension could use a feature that checks if you can dash just like you can with air jumps (In otherwords, the Dash equivalent of the “Can Jump” check). Would help make it easier to do this. So if anyone here can contact the person who made the extension, mind bringing this post to them. Thanks in advance.

Alright, figured out my problem. Apparently one of my other commands weren’t playing nice with my dash command and now it works as intended. My previous message is still valid, but for now, Case Closed

1 Like