How to cast multiple line traces to check a circle area around an actor?

Hi everybody.

I’m working on a semi-seeking projectile that will fire straight ahead but if a targetable actor comes within a specified radius, it will set the actor as it’s target and switch to become a homing projectile.

I have everything working except I can’t figure out how to cast multiple traces at specific intervals around the character to cover that specific area. It’s likely some relatively simple vector math that i just don’t know yet (trying to learn) but any ideas or suggestions would be greatly appreciated.

Just for the record, I initially tried doing this with an overlap volume on the projectile but that resulted in that volume being part of the projectile so it just halted on the target at the overlap point rather than seeking it based on the internal collision volume.

That’s it exactly. Although now I’m wondering WTH is going on as the sphere trace isn’t picking anything up.

1 Like

I was able to resolve the failed trace issue by restarting the Editor and that is giving me exactly what I needed! Submit it as an answer so I can mark it :slight_smile:

Thanks for your help man. I really appreciate it.

Wouldn’t that be a lot more expensive since there could be dozens of these and everything is confined to an XY plane?

Not sure about the performance, probably depends on how many traces you want and how often.
Is this what you’re trying to achieve? Maybe I misunderstood you.

1 Like

Why don’t you use a sphere trace on a timer?

How about this:

No tracing, just an overlap on a separate channel:

Image from Gyazo

Since we’re using a custom collision channel here, it’s all filtered and pretty efficient. And can be put on a timer instead of tick if necessary.

Projectile:

Its target:

And yet another way in case obstructions need to be taken into account.

Rather than tracing x times all the time, sphere trace to check for obstructions only and only against the targets that fit the criteria - are in range:

  • start checking the distances between the projectile and targets after firing, immediately rejecting targets exceeding range
  • sphere trace against that list in order to reject obstructed targets

Now you have a list of targets that are both unobstructed and in range. Again, this keeps the tracing to minimum - you will never need more sphere traces than targets.


Not sure whether this is more efficient than any other suggested method. Probably irrelevant.

Thanks man, exactly what I was looking for.