Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!

traceline

From Quake Wiki

Revision as of 01:20, 25 March 2013 by Necros (talk | contribs) (Created page with "====Syntax:==== <code>void traceline(vector v1, vector v2, float collisionType, entity ignore)</code> This function traces a line between v1 and v2 and sets many global varia...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Syntax:

void traceline(vector v1, vector v2, float collisionType, entity ignore)

This function traces a line between v1 and v2 and sets many global variables depending on the results of the trace.

Parameters:

v1 - The start point of the trace
v2 - The end point of the trace
collisionType - How the trace interacts with other entities. 0 makes it collide with both the world and solid entities' bounding box. 1 makes it not collide with monsters (solid entities with the FL_MONSTER flag set on .flags). 2 makes the trace extra wide against monsters.

Returns:

void

Global variables affected:

float trace_allsolid - (?)
float trace_startsolid - (?)
float trace_fraction - The fraction of the total length of the vector v2 - v1 that was traced before the trace hit an obstacle.
vector trace_endpos - The coordinates of the end point of the trace. If the trace did not hit anything, than trace_endpos = v2, otherwise it will report the position where the trace hit an obstacle.
vector trace_plane_normal - The normal of the plane that was hit by the trace.
float trace_plane_dist - The distance of the plane to the world origin (?)
entity trace_ent - The entity that was hit by the trace (if nothing was hit, returns world).
float trace_inopen - If the trace is in open air (?)
float trace_inwater; - If the trace is in water (?)