Currently teaching myself c++ and I am in the process of converting a blueprint function I wrote to manage recently hit actors in melee combat from some line traces.
I check to see if an Attacker is Contained in a map and if not I add that actor and its currently active montage to the map, send off the hit and then do a for each loop on the map keys, find the value and check if the the montage is still playing, If not I delay until next tick and check again, until the montage is no longer playing and then remove the attacker from the map.
I’ve included Screenshots of both BP and Cpp, Any insight would be greatly valued. Thanks
Real talk: Your blueprint version probably doesn’t actually work, it only seems to because the array only ever has one element in it.
Because of the way the Blueprint VM and latent nodes work, you don’t get the behavior that you expect. Primarily once you start processing the latent execution, every check will be against the last element of your array. Not the element that the latent node was on when you hit it repeatedly.
Your C++ is causing the game to hang because once you call ManageHitsFilter, you never return from it and give the engine a change to do anything ever again. CheckIfRecentlyHit would either have to 1) start a timer (here) or 2) add to a member variable that your UCombatComponent does the filtering on during it’s TickComponent.
In either case you’d check all the elements once (no do/while) and then wait for the timer/tick to happen again before checking them again.
Hey Thanks for the replay, Yeah I have since learned more about the execution of C++, I ended up making a delegate to fire at the end of the montage and its working great.
I’m not sure with the blueprint but you could be right, It did seem to work perfectly the way i had it.
Its checking a Map though so the montage is tied to a specific actor and its only ever checking the montage for that actor and removing it from the map if the montage is not playing.