Line trace for specified Actor

Is there any simpler way to do a line trace for Actor than repeating the trace until it hits the actor or doesn’t hit anything?

you could put the line trace into a for loop and then continually modify the start point and end point until your final condition is met

though lets look at some alternatives and why:
a LineTrace works best when we know an absolute start point and an absolute end point, so if we say want to find if there is line of sight to a thing we will grab the other thing directly, do a line trace single to the other object and see if we hit the other object before anything else (if so it is occluded and we “probably” don’t have line of sight)
*how you get the other object has a few options as well

  • Find All Actors of Class() which will give us an array we can step though to find a specific one if needed (if there is only ever to be one of the class then we can do Find Actor of Class().
  • doing a Sphere Trace Multi for Objects() which will return an array of all the objects that match the type from a knows origin, and in a 360x360 sphere by a known radius
  • we can get the object from some manager that already has a pointer/reference to the object for “quick” resolution so we don’t have to do a trace or potentially have the World check every Actor.

another method if we “know” the line we want to check we can do a LineTraceMulti to see if the object of interest is on that line at all (this will return an array, so may need to step through it.

1 Like

Use multi line trace.
You can then foreach and cast, or you can set up a custom channel for your actor if you feel that’s necessary.

It seems like an odd operation to want to perform. What are you trying to achieve?

1 Like