"First-person hide must cover all renderer descendants"
▸ SYMPTOM
You switch to first-person view by setting the citizen body's SkinnedModelRenderer to ShadowsOnly. The body disappears, but clothing items (hats, vests, accessories) remain visible, clipping through the camera's near plane at eye level.
▸ CAUSE
ClothingContainer.Apply spawns a separate SkinnedModelRenderer for each clothing item as a child of the character. Toggling only the body renderer leaves every clothing renderer at its default RenderType.On. Each clothing piece renders independently and clips into the first-person camera.
▸ FIX
Enumerate every ModelRenderer descendant at toggle time:
void SetFirstPerson( GameObject visual, bool firstPerson )
{
var type = firstPerson
? ModelRenderer.ShadowRenderType.Off
: ModelRenderer.ShadowRenderType.On;
foreach ( var r in visual.Components.GetAll<ModelRenderer>(
FindMode.EnabledInSelfAndDescendants ) )
{
r.RenderType = type;
}
}Key details:
- Enumerate at toggle time, never cache a spawn-time list — outfit swaps change the renderer set.
- Use
RenderType.Off(notDestroy) so the component remains enabled and re-findable when switching back to third person. - Use
FindMode.EnabledInSelfAndDescendantsto catch all nested clothing renderers.
▸ WHY IT WORKS
The clothing system creates renderers dynamically as children of the character hierarchy. Any first-person visibility toggle that targets only the body renderer misses these children. Enumerating all ModelRenderer descendants at the moment of the toggle guarantees every current renderer — body, hat, vest, shoes — gets the same render type, regardless of what outfit is equipped.