TraceCallback
Usage
This is called during a trace when any Actor in the blockmap is hit, any line is hit, or any plane is hit. This can also be called when crossing portals if set to do so. Custom logic handling for what happens when something is hit happens in this function. Generally Results' HitType is looked at to determine what should be examined in the results.
Return value
Returns the status of the trace. The status is used to determine whether to keep going or terminate the trace at that spot. Can be one of the following values:
- TRACE_Stop - Terminates the trace at its current spot, returning the results from the current hit
- TRACE_Continue - Tells the trace to keep going. If nothing else is hit along the way, the results from the current hit will be returned
- TRACE_Skip - Similar to TRACE_Continue but will not return the results from the current hit
- TRACE_Abort - Similar to TRACE_Stop but will not return the results from the current hit
Examples
class GhostFinder : LineTracer
{
bool bHitGhost;
// This is where we'll examine the results to check for ghosts
override ETraceStatus TraceCallback()
{
// Check if we hit an actor. If so, does it have the ghost flag?
if (results.HitType == TRACE_HitActor && results.HitActor.bGhost)
{
bHitGhost = true;
// Tell the trace to terminate
return TRACE_Stop;
}
// If we didn't hit an actor or it doesn't have the ghost flag, ignore it and keep going
return TRACE_Skip;
}
}
Internal Code
virtual ETraceStatus TraceCallback() { // Normally you would examine Results.HitType (for ETraceResult), and determine either: // - stop tracing and return the entity that was found (return TRACE_Stop) // - ignore some object, like noclip, e.g. only count solid walls and floors, and ignore actors (return TRACE_Skip) // - find last object of some type (return TRACE_Continue) // - stop tracing entirely and assume we found nothing (return TRACE_Abort) // TRACE_Abort and TRACE_Continue are of limited use in scripting. return TRACE_Stop; // default callback returns first hit, whatever it is. }
This article is issued from Zdoom. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.