Event A is bind on another actor event, and Event B is also bind on something. And the sequence to be activated of the two events is not always the same. Sometimes Event A reaches earlier, and sometimes Event B reaches eariler. And I have to wait for thoes two event all activated so the timing is correct.
Althogh the macro node in picture can work, it has two bad outcomes when I’m using it:
When I need to wait for more events, I have to make a new macro and add more execute pin at the front.
Inside the macro I only use one local integer to count the event num, thus I need to use DoOnce on every event incase some event fired too frequently.
I think many developers would meet this situation, but I cannot find tutorials contained or metioned the best way to handle this situation. So put this question on the forum for the best answer.
PS:
I can’t create an array contains many delegate pins. (Delegate pin is the red pin on the event node.)
The delegate pin doesn’t have GetEventName() function.
I could use a string to represet the event using event name, and check the string inside the macro like this:
Replace that for loop with a Array->Contains->False. If any are false, then you can exit.
I’m still thinking if there’s any way that isn’t more hell than it’s worth to give it a variable number of inputs, but I’m pretty sure you’d have to go into some fairly complex native code to get there. Might be doable with a simple CommutativeAssociativeBinaryOperator function, but I’ve never used that, so not entirely sure. Probably can if there’s a way to suss out how many pins are enabled.
Though, overall I question if this is needed frequently enough to try to make a generic solution for… why is it needed so much?
In general, for N events, you need N separate flags (bools?) that you can set.
Then, after setting a flag, you check whether all flags are set, and if they all are, do the next thing.
You could wrap this up in some state object that keeps an array of bool values, for example, if you want to make it re-usable and re-sizable.
However, this kind of situation is exactly what the gameplay ability framework is designed to do.
You define gates, and events, and actions, and the system will take care of activating the right outcome when the right circumstances occur.
You do need a little bit of C++ to set up the GAS, but once that’s done (Reubs has a good YouTube video that shows you how in half an hour,) then it’s pretty easy and flexible to use.
But since it’s using timer to check and I set interval is 0.1 sec, the overhead could be a problem. And the trigger is no longer precise collision, which means it’s not suitable for action game and shooting game.