"A Scene.Trace only reports a model hitbox when it opts in with UseHitboxes(true)"
▸ SYMPTOM
You fire a Scene.Trace at a character wired for hit zones and read SceneTraceResult.Hitbox to tell a head shot from a body shot. It always comes back null.
If that character carries model hitboxes and no body collider, the trace is worse than null: the ray passes straight through and reports hit=False. You get no hit at all, not a hit with a null hitbox. Verified on engine 26.08.05.
▸ CAUSE
A Scene.Trace ignores model hitboxes unless the trace opts in with .UseHitboxes(true). With the flag omitted, the trace tests colliders only.
A hitbox-only target has no collider for a plain trace to hit, so the ray finds nothing along its path.
The result type is a Sandbox.Hitbox. It carries .Tags (an ITagSet), .Bone, and .GameObject.
▸ FIX
Wire the target with the Sandbox.ModelHitboxes component:
- Set
.Rendererto theSkinnedModelRenderer. - Set
.Targetto the GameObject the trace result should name. - Call
Rebuild().
Then set the flag on every trace that must see those hitboxes:
var tr = Scene.Trace
.Ray( start, end )
.UseHitboxes( true )
.Run();
if ( tr.Hit && tr.Hitbox is not null )
{
// tr.Hitbox.Tags is an ITagSet: "head", "spine chest", "leg right upper"
// tr.Hitbox.Bone and tr.Hitbox.GameObject name what was struck
}Against a stock humanoid model wired this way, the trace resolved 20 hitboxes (head, spine_2, leg_upper_R and the rest), each carrying the model author's tag set. The identical ray with the flag omitted came back hit=False.
Give a hitbox-precision target no body collider. If it carries both a coarse body collider and hitboxes, the collider shadows the hitboxes: the nearer collider hit wins, Hitbox comes back null, and a head shot resolves silently as a body hit.
▸ WHY IT WORKS
.UseHitboxes(true) is the switch that adds per-bone hitbox geometry to what the trace tests. Without it the trace sees colliders only, so a hitbox-only character is transparent to the ray. A coarse collider sits closer to the ray origin than the fine hitboxes behind it, so once both are present the collider hit is the one the trace returns. Removing the body collider leaves the hitboxes as the only thing to hit, which keeps the returned Hitbox and its bone tag accurate.
- Published.