How to trace actors?

Hello.
I am working on lock on system and at the moment I am relying on “Get All Actors Of Class” to find all targets. The problem is that it tracks them no matter where they are. Is there any way to trace all actors of my custom class just in front of my camera?

you can use a raycast https://docs.unrealengine.com/en-us/Gameplay/HowTo/UseRaycasts

Here’s another solution

  • create a Radar actor with a front facing cone, scale it as need and make it Hidden in Game and set to Overlapping Collision
  • add it to your Pawn as a child actor, offset position as desired
  • during Pawn’s Tick, Radar Child Get Overlapping Actors of the Target class and Loop

Looks crazy but works like a charm and gives you the potential to easily implement additional functionality. Like pointing the radar at things or rotating it around to detect targets.


What Nico_Pucho_27 is suggesting is a grown up approach that would work well providing you know the basics of trigonometry.

I tried using trace but problem with that is that it doesn’t give you actor (cyan one) but whatever blue means.
If you know how to change that I would love to know how to do it. It might come in handy.

It does give you blue pin Actors, you need to do a ForEachLoop first and then break the Hit Result string.