Hosting and domain costs until October 2024 have been generously sponsored by dumptruck_ds. Thank you!
Difference between revisions of "traceline"
From Quake Wiki
(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...") |
m (→Parameters) |
||
(3 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
− | + | ''void'' '''traceline'''(''vector'' start, ''vector'' end, ''float'' collisionType, ''entity'' ignore) | |
− | |||
− | + | == Usage == | |
− | + | Fires out a line from the starting position to the ending position, colliding with anything based on the passed collision type. Sets the following globals: | |
− | + | *'''trace_allsolid''' | |
− | + | :If <code>TRUE</code>, the trace was stuck entirely in solids. | |
− | + | *'''trace_startsolid''' | |
− | + | :If <code>TRUE</code>, the trace started inside of a solid. | |
− | + | *'''trace_fraction''' | |
− | + | :The fraction of the total distance the trace traveled before stopping. Ranges from [0, 1]. | |
− | :<code> | + | *'''trace_endpos''' |
− | + | :The position the trace stopped. | |
− | :<code> | + | *'''trace_plane_normal''' |
− | : | + | :The normal of the plane that the trace hit. |
− | : | + | *'''trace_plane_dist''' |
− | : | + | :The distance from the world origin of the plane that the trace hit. This is d in the plane equation ax + by + cz + d = 0. |
− | : | + | *'''trace_ent''' |
− | :<code> | + | :The entity that the trace hit. |
− | :<code> | + | *'''trace_inopen''' |
+ | :If <code>TRUE</code>, the trace traveled through open air. | ||
+ | *'''trace_inwater''' | ||
+ | :If <code>TRUE</code>, the trace traveled through a liquid. | ||
+ | === Parameters === | ||
+ | *''start'' | ||
+ | :The starting position of the trace. | ||
+ | *''end'' | ||
+ | :The destination position of the trace. | ||
+ | *''collisionType'' | ||
+ | :The type of entities considered valid when checking collision. Can be one of the following: | ||
+ | :*<code>0</code> (Collide with everything) | ||
+ | :*<code>1</code> (Only collide with entities that have a solid type of <code>SOLID_BSP</code>) | ||
+ | :*<code>2</code> (Collide with everything but use an extended pseudo bounding box against entities with the <code>FL_MONSTER</code> flag) | ||
+ | *''ignore'' | ||
+ | :The entity to ignore collision of while tracing. | ||
+ | == Example == | ||
+ | // This fires out a trace to see if it hit an entity. If it did, it deals damage | ||
+ | traceline(self.origin, self.origin + v_forward*128, 0, self); | ||
+ | if (trace_ent && trace_ent.takedamage != DAMAGE_NO) | ||
+ | T_Damage(trace_ent, self, self, 20); | ||
[[Category:QuakeC Function]] | [[Category:QuakeC Function]] |
Latest revision as of 11:39, 2 August 2023
void traceline(vector start, vector end, float collisionType, entity ignore)
Usage[edit]
Fires out a line from the starting position to the ending position, colliding with anything based on the passed collision type. Sets the following globals:
- trace_allsolid
- If
TRUE
, the trace was stuck entirely in solids.
- trace_startsolid
- If
TRUE
, the trace started inside of a solid.
- trace_fraction
- The fraction of the total distance the trace traveled before stopping. Ranges from [0, 1].
- trace_endpos
- The position the trace stopped.
- trace_plane_normal
- The normal of the plane that the trace hit.
- trace_plane_dist
- The distance from the world origin of the plane that the trace hit. This is d in the plane equation ax + by + cz + d = 0.
- trace_ent
- The entity that the trace hit.
- trace_inopen
- If
TRUE
, the trace traveled through open air.
- trace_inwater
- If
TRUE
, the trace traveled through a liquid.
Parameters[edit]
- start
- The starting position of the trace.
- end
- The destination position of the trace.
- collisionType
- The type of entities considered valid when checking collision. Can be one of the following:
0
(Collide with everything)1
(Only collide with entities that have a solid type ofSOLID_BSP
)2
(Collide with everything but use an extended pseudo bounding box against entities with theFL_MONSTER
flag)
- ignore
- The entity to ignore collision of while tracing.
Example[edit]
// This fires out a trace to see if it hit an entity. If it did, it deals damage traceline(self.origin, self.origin + v_forward*128, 0, self); if (trace_ent && trace_ent.takedamage != DAMAGE_NO) T_Damage(trace_ent, self, self, 20);