SetSolid(): Difference between revisions

From Valve Developer Community
Jump to navigation Jump to search
(object-aligned bounding boxes DO work!)
m (Setting bug notice hidetested=1 param on page where the bug might not need tested in param specified)
 
(6 intermediate revisions by 2 users not shown)
Line 1: Line 1:
'''<code>SetSolid()</code>''' defines the manner in which collisions between this entity and others are handled. <code>[[SetSolidFlags()]]</code> can be used to tweak behaviour further.
'''<code>SetSolid()</code>''' defines the manner in which this entity's collisions are handled. <code>[[SetSolidFlags()]]</code> can be used to tweak behaviour further.


{{note|Behaviour can change subtly depending on whether the object is colliding or being collided ''with''.}}
{{note|Behaviour can change subtly depending on whether the object is colliding or being collided ''with''.}}
Line 6: Line 6:


; <code>SOLID_NONE</code>
; <code>SOLID_NONE</code>
: The entity does not generate its own collisions. Depending on the [[SetMoveType()|MoveType]], its [[origin]] may still collide with [[brush]]es but will <code>[[Touch()]]</code> unreliably. {{tip|Use <code>SetMoveType(MOVETYPE_NOCLIP)</code> to completely disable all movement collision.}}
: The entity does not generate its own collisions. Depending on the [[MoveType]], its [[origin]] may still collide with [[brush]]es but will <code>[[Touch()]]</code> unreliably. {{tip|Use <code>SetMoveType(MOVETYPE_NOCLIP)</code> to completely disable all movement collision.}}
; <code>SOLID_BSP</code>
; <code>SOLID_BSP</code>
: The entity has a [[brush]] model defined by the map. Collides with <code>SOLID_BBOX</code> and <code>SOLID_VPHYSICS</code> objects, but not other <code>SOLID_BSP</code>s.
: The entity has a [[brush]] model defined by the map. Does not collide with other <code>SOLID_BSP</code> entities.
; <code>SOLID_BBOX</code>
; <code>SOLID_BBOX</code>
: The entity collides with an axis-aligned [[bounding box]]. Collides with everything. Required for [[hitbox]] tests. {{tip|Use <code>[[UTIL_SetSize()]]</code> to define the extents of the box. But remember to stop calling it if the entity changes to another SolidType, or you will get a crash that disappears when a debugger is attached!}}
: The entity collides with an axis-aligned [[bounding box]]. Collides with everything. Required for [[hitbox]] tests.
: Use <code>UTIL_SetSize()</code> to define the extents of the box. {{bug|hidetested=1|Stop calling SetSize if the entity changes to another SolidType, or you will get a crash that disappears when a debugger is attached!}}
; <code>SOLID_OBB</code>
; <code>SOLID_OBB</code>
; <code>SOLID_OBB_YAW</code>
; <code>SOLID_OBB_YAW</code>
: The entity collides with an [[object-aligned bounding box]]. Call <code>[[VPhysicsInitShadow()]]</code> if you use this ({{todo|Is it genuine VPhys collision, or a hybrid, or what?}}).
: The entity collides with an [[object-aligned bounding box]]. <code>OBB_YAW</code> restricts orientation to the Z-axis. <code>UTIL_SetSize()</code> can be used to define the box's extents.
: <code>OBB_YAW</code> restricts orientation to the Z-axis.
; <code>SOLID_CUSTOM</code>
; <code>SOLID_CUSTOM</code>
: <code>[[TestCollision()]]</code> is called every frame to handle collisions. {{todo|Relationship with <code>FSOLID_CUSTOMRAYTEST</code> and <code>FSOLID_CUSTOMBOXTEST</code>?}}
: <code>TestCollision()</code> is called every frame to handle collisions. {{todo|Relationship with <code>FSOLID_CUSTOMRAYTEST</code> and <code>FSOLID_CUSTOMBOXTEST</code>?}}
; <code>SOLID_VPHYSICS</code>
; <code>SOLID_VPHYSICS</code>
: Use [[VPhysics]] for collisions. Collides with everything. Call <code>[[VPhysicsInitNormal()]]</code> or <code>[[VPhysicsInitShadow()]]</code> if you use this!
: Loads a [[collision mesh]] from the entity's [[model]]. This results in the same collision shape as [[VPhysics]] would have, without actually enabling VPhysics collisions or simulation.


== See also ==
== See also ==

Latest revision as of 07:14, 20 May 2025

SetSolid() defines the manner in which this entity's collisions are handled. SetSolidFlags() can be used to tweak behaviour further.

Note.pngNote:Behaviour can change subtly depending on whether the object is colliding or being collided with.

SolidTypes

SOLID_NONE
The entity does not generate its own collisions. Depending on the MoveType, its origin may still collide with brushes but will Touch() unreliably.
Tip.pngTip:Use SetMoveType(MOVETYPE_NOCLIP) to completely disable all movement collision.
SOLID_BSP
The entity has a brush model defined by the map. Does not collide with other SOLID_BSP entities.
SOLID_BBOX
The entity collides with an axis-aligned bounding box. Collides with everything. Required for hitbox tests.
Use UTIL_SetSize() to define the extents of the box.
Icon-Bug.pngBug:Stop calling SetSize if the entity changes to another SolidType, or you will get a crash that disappears when a debugger is attached!
SOLID_OBB
SOLID_OBB_YAW
The entity collides with an object-aligned bounding box. OBB_YAW restricts orientation to the Z-axis. UTIL_SetSize() can be used to define the box's extents.
SOLID_CUSTOM
TestCollision() is called every frame to handle collisions.
Todo: Relationship with FSOLID_CUSTOMRAYTEST and FSOLID_CUSTOMBOXTEST?
SOLID_VPHYSICS
Loads a collision mesh from the entity's model. This results in the same collision shape as VPhysics would have, without actually enabling VPhysics collisions or simulation.

See also