Hi, I want to detect when my multi sphere trace adds and removes new actors, so I can call detection events. But I can’t seem to figure this out, or maybe I’m just too tired.
I actually managed to trigger new hits, but I can’t figure out how to detect when it stops hitting something.
Create an actor component with a timer on begin play. When trace hits, check for a MyTraceHitComponent. If not found then add it and a reference of the actor to the array, if found then reset the timer. When the timer runs out remove the component. The components life can help manage the the reference in the trace actor. An actor tag could also be added with the component to check against.
For a lot of hits: Add the hit actors to a map<reference, float> where the float is the life of the actor in the map. On every trace check if the hit actor is in the map; if found reset the float. Loop the keys to decrement the value by elapsed time from last frame. If float <= 0.0, remove from map.
For both the idea is to manage the time without having to search an array multiple times.
Ok I think I figured it out. I have a branch for checking if the multi sphere trace has hit something. Initially it works since there was never anything hit, but when I want to check for actors stopped being hit, if there was only one hit and now there’s none, the branch is stopping it from doing anything, so it doesn’t work.
Just removing the branch node from my screenshot fix it.