How could I get the current target in a first person view?


I would like to know how can i get the current target in a first person view.
I have a crosshair, and how can i get the actor i am looking at? Is there a built in function or i have to loop through all actors and find the closest one?

Use “Single Line Trace For Object”.

You can set “start location” as camera location, end location as "camera’s forward + 100000 (the length of Target Searching)

And there is a return value called “OutHit”

Spilt it and you can see “Out Hit Hit Actor”. this is what the trace hit.


trace for objects can be annoying. mainly cause you have to make an ObjectTypes array, and it boggled my mind how to make it when i was(probably still am) a noob.

trace for channel works quicker, but only if you know/have setup what channel your target actor is on… i think the default is WorldDynamic.

I already figured out i can use tracing method to find the target. I was hoping there is a built in function for this.
Thanks anyway.