Implement the following plan: Fix: Silhouette Y-sort not using collider bottom…
- User
Implement the following plan:
Fix: Silhouette Y-sort not using collider bottom coordinate
Context
When collider children (e.g.,
pete-collider,Boldo-collider) are applied to parent entities,ApplyColliderChildsetsYSortOffseton the parent'sSpriteInfoso it Y-sorts by the collider's bottom edge. However, child entities like silhouettes (e.g.,elephant-kid-shilhouette) never receive thisYSortOffset. They sort byWorldPosition.Y + 0(entity center) instead of by the collider bottom.This means: when the player walks behind an NPC, the NPC sorts correctly (by collider bottom), but the silhouette sorts by a higher Y value (entity center), causing it to appear in front of the player when it should be behind.
Execution order in the parser
- Pre-scan: Identify collider children
- Pass 1: Create entities + run collection handlers (sets
YSortDepthBiason silhouettes) - Post-Pass 1:
ApplyColliderChild→ setsYSortOffseton parent only - Pass 2: Set up parent-child hierarchy
YSortOffsetisn't available during Pass 1 (when the NPC collection handler runs), so the silhouette can't copy it at that point.Fix
Add a propagation step after Pass 2 in
BlenderLevelParserSystem.cs(line ~174) that copiesYSortOffsetfrom parent to child entities that haveSpriteInfo:csharp// Post-Pass 2: Propagate YSortOffset from parents to sprite children foreach (var obj in levelData.Objects) { if (string.IsNullOrEmpty(obj.Parent)) continue; if (colliderChildNames.Contains(obj.Name)) continue; if (!_nameToEntity.TryGetValue(obj.Name, out var childEntity)) continue; if (!_nameToEntity.TryGetValue(obj.Parent, out var parentEntity)) continue; if (childEntity.Has<SpriteInfo>() && parentEntity.Has<SpriteInfo>()) { ref readonly var parentSprite = ref parentEntity.Get<SpriteInfo>(); if (parentSprite.YSortOffset != 0f) { ref var childSprite = ref childEntity.Get<SpriteInfo>(); childSprite.YSortOffset = parentSprite.YSortOffset; Logger.Debug($"Propagated YSortOffset={parentSprite.YSortOffset} from '{obj.Parent}' to '{obj.Name}'."); } } } Assistant
Let me start by reading the file that needs to be modified.
Assistant
Now I'll add the YSortOffset propagation step after Pass 2 (after line 174).
Assistant
Now let me build to verify it compiles.
Assistant
Build succeeds with 0 errors. The fix adds a Post-Pass 2 propagation step at line 176 in
BlenderLevelParserSystem.csthat iterates over all child objects with parents and copies the parent'sYSortOffsetto child entities that haveSpriteInfo. This ensures silhouettes (and any other sprite children) Y-sort by the same collider bottom coordinate as their parent, fixing the rendering order when the player walks behind NPCs.- User
(/Users/rodrigooliveira/Desktop/Captura de Tela 2026-02-23 às 14.45.42.png) It's almost perfect, there is just one corner case when the player (the penguin) is right in the middle height probably where the YSorting change happen: the player is sorted behind the elephant-kid but above the elephant-kid-shilhouette. Using the in-game inspector I tried to watch the Transforms but couldn't find the transforms for the colliders or a way to view them, they appear as an opaque object name instead of readable properties (can you fix that as well?)
- User
[Image: image/png]
Assistant
Let me read the existing plan file and then explore the codebase to understand both issues.
Assistant
Now I can see the screenshot clearly. The inspector shows
ConvexColliderwithModelVertices: Microsoft.Xna.Framework.Vector2[]andWorldVertices: Microsoft.Xna.Framework.Vector2[]— just type names instead of actual values. Let me explore the codebase to understand the Y-sort system and the inspector implementation.Assistant
Good, now I have a clear picture. Let me read the key files to understand the exact details before designing the fix.
Assistant
Now let me find the collection handler that sets
YSortDepthBiason silhouettes and understand how the elephant-kid entities are set up.Assistant
Let me check how
EntityHierarchyworks and verify how to access parent entities at runtime.Assistant
Let me also look at the full NPC collection handler context to understand the silhouette setup.
Assistant
Now I have all the information I need. Let me write the plan.
- User
[Request interrupted by user for tool use]