How to fire an event once every time a multi sphere trace hits a new actor, and another event when it stops hitting an object?

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.

here’s what I’ve got:

Ideas?

I thought this was gonna work:

but it doesn’t. can’t find out why

I’ll bump this one, cause it seems to me this should be trivial, but for some reason I can’t figure it out

A couple of alternatives:

  1. 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.
  2. 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.

Thanks for replying.

This would be an alternative to the multi sphere trace, but that’s working for me.

I’d still have to manage the hit checks to fire the events appropriately, which is what I’m having problems with.

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.

Dumb mistake, easy fix heh

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.