The three virtues of a programmer: Laziness, Impatience, and Hubris. – Larry Wall
A trace is a line check against relevant collision primitives of actors in the level.
|This article is a stub. You can help Unreal Wiki by expanding it.|
The engine provides multiple ways to perform line checks. Additionally it perfoms line checks internally when moving actors.
The most obvious choice. The Trace function performs a line check from a start location to an end location and returns the actor hit closest to the start location. Internally it still needs to find all hits and sort them by distance from the start to find the first hit.
You can pick whether you want to trace for only world geometry (BSP, movers, anything marked as bWorldGeometry) or all actors a projectile could hit (world geometry and any colliding actors that have bProjTarget or bBlockActors). Certain special cases, like tracing WaterVolumes or limiting trace results to only Pawns, can be enabled via actor properties. You likely won't find regular pickups using the Trace function, because they are not projectile targets. (Unless, for example, you are playing with "Volatile Ammo".)
This function checks only against BSP, Movers and bWorldGeometry. It only returns whether there was a hit or not, but does not provide any information about the hit whatsoever. As the name suggests, this is likely the fastest way to perform a trace, but you are limited in the tracing targets.
Performs a trace and then lets you iterate over the hits. Like Trace, it will sort the hits by their distance from the start location.
TraceActors considers all colliding actors, even if they are not projectile targets, but of course it only returns hits that pass the class filter you specified. This is probably the most complete trace function you will find.
Performs a trace only against the collision primitive of the actor or component it was called on, regardless of that actor's collision settings. You can use this function when you already know what you are likely going to hit, but want to figure out exactly how the hit will connect. This function is even faster than FastTrace, but obviously has different applications than that.
Alternative ways of tracing
If the above functions do not satisfy your needs, there are also other ways to probe for collisions along a certain path.
If everything else fails, you can always spawn an actor with the collision settings you need an move it along the path you want to trace. You can use its Touch or HitWall events to collect any hits it encounters. To move it along a particular path, you can set up its Velocity and/or Acceleration and then call the AutonomousPhysics function to have the actor perform its configured physics as if the specified amount of game time passed. Alternatively you can use the Move function to specify a location offset to move the actor along, but Touch/Untouch notification may not be useful other than signaling that there was a collision.