Hitboxes

From Valve Developer Community
Jump to: navigation, search
简体中文

Hitboxes are bounding boxes aligned to skeleton parent joints. They are used by various systems in the game, some examples include but are not limited to hit detection, character selection, and particle emission.

Display

  • To toggle hitbox display go Display > Hit Boxes.
  • To toggle hitbox name display go to Display->Hit Box Names.
  • If there are multiple sets present Display->Sets allows set visibility to be toggled by name.

Create

  • Right-click on a joint item in the outliner, and select Add Hitbox.
  • Use the Model > Hitboxes menu items.

Edit

  • When a hitbox is selected via the viewport or an outliner item the gizmo becomes available. Use the gizmo to scale the size of the hotbox. Two modes are available, scale and box scale.
  • When selected the editable properties of a hitbox are accessible via the Property Editor.

Data Structures

The vmdl hitbox data looks like this:

CVhitBoxSetListReference[] m_pHitBoxSetLists = 
[
	CVhitBoxSetListReference
	{
		CVhitBoxSetList* m_pObject = &CVhitBoxSetList_0
		string m_sFileName = ""
	}
]

m_pHitBoxSetLists

A list of CVhitBoxSetListReference elements.

CVhitBoxSetListReference

A reference to an internal or external CVhitBoxSetList.

Attribute Friendly Name Description Type Default Value
m_pObject pointer to the internal CVhitBoxSetList CVhitBoxSetList*
m_sFileName content relative path to the external CVhitBoxSetList string

A hitbox set list looks like this:

CVhitBoxSetList CVhitBoxSetList_0
{
	CVhitBoxSet[] m_HitBoxSets = 
	[
		CVhitBoxSet
		{
			string m_name = "default"
			CVhitBox[] m_HitBoxes = 
			[
				CVhitBox
				{
					string m_name = "spine_0"
					string m_sSurfaceProperty = ""
					int m_nGroupId = 0
					string m_sBoneName = "spine_0"
					float(3) m_vMinBounds = ( -3.769234, -4.263324, -6.618944 )
					float(3) m_vMaxBounds = ( 5.111142, 5.840798, 6.613623 )
					uint(4) m_cRenderColor = ( 0, 0, 0, 0 )
				},
				CVhitBox
				{
					string m_name = "head_0"
					string m_sSurfaceProperty = ""
					int m_nGroupId = 0
					string m_sBoneName = "head_0"
					float(3) m_vMinBounds = ( -3.821239, -3.392044, -3.581856 )
					float(3) m_vMaxBounds = ( 6.065765, 5.141216, 3.582397 )
					uint(4) m_cRenderColor = ( 0, 0, 0, 0 )
				}
			]
		}
	]
}


CVhitBoxSetList

Contains a list of CVhitBoxSet elements.

Note:When it is made external, a hitboxsetlist is saved as a ".hitboxes" file.

CVhitBoxSet

Contains a list of CVhitBox elements.

Attribute Friendly Name Description Type Default Value
m_name Name The name of the hitbox string

CVhitBox

The data description of the hitbox.

Attribute Friendly Name Description Type Default Value
m_name Name The name of the hitbox string
m_sSurfaceProperty Surface Property surface property assigned to the hitbox string
m_nGroupId Group ID Group ID, used by game code to query hitboxes int 0
m_sBoneName Parent Bone Name of the parent joint string
m_vMinBounds Min Minimum bounds of the hitbox float(3) < 0, 0, 0 >
m_vMaxBounds Max Maximum bounds of the hitbox float(3) < 0, 0, 0 >
Note:m_cRenderColor is no longer used.
Note:Hitboxes are defined as a bounding box aligned to the parent joint, they have no rotation value.
Tip:A joint can have multiple hitboxes associated with it.