Revision Difference
Hitboxes#549184
<cat>Code.Physics</cat>
<title>Hitboxes</title>
# Using Hitbox Tags
We removed hitgroups in favour of Hitbox Tags, similar to how we use them for collisions. Here's how they work.
## ModelDoc
When editing a hitbox from ModelDoc, you'll see Hitbox Tags. Populate them with some useful keywords like so:
<upload src="97/8dab065acd70d6e.png" size="18164" name="image.png" />
<note>You don't need to update the Citizen's hitbox tags, we've done that for you</note>
## Trace.Ray and Entities
To be able to hit a Hitbox with a Trace.Ray, you must call `UseHitboxes()` on it before `Run()`:
```csharp
TraceResult tr = Trace.Ray(Camera.Position, Camera.Position + Camera.Rotation.Forward * 100)
.Ignore(this)
.UseHitboxes()
.Run();
```
Also for the Entity, during its spawning it needs to have `EnableHitboxes` set:
```csharp
EnableHitboxes = true;
```
or your ray will just hit its collision box, even when you set `UseHitboxes()`.
## API
When running traces, you'll see TraceResult.Hitbox. That'll hold all the info you'll need when interacting with hitboxes. We also pass it with DamageInfo.
Before, you'd be given a hitbox index, and that's it. It wasn't elegant at all.
With hitbox tags, it's way more explicit:
```csharp
...
var isHeadshot = damageInfo.Hitbox.HasTag( "head" );
if ( isHeadshot )
{
// Multiply headshot damage by 2
damageInfo.Damage *= 2f;
}
```
You can also grab the hitbox's name with [Hitbox.GetName()](https://asset.party/api/Hitbox.GetName()) - useful for debugging.
You can also grab the hitbox's name with [Hitbox.GetName()](https://asset.party/api/Sandbox.Hitbox.GetName()) - useful for debugging.