To achieve this effect where a character can be partially hidden behind objects like trees, you need to work with slot draw order in Spine rather than trying to control z-index in Godot.
The Solution: Multiple Slots with Proper Draw Order
The key is to organize your skeleton into multiple slots that represent different depth layers:
In Spine Editor, create separate slots for different parts of your character:
back slot (for parts that go behind trees)
middle slot (for the tree/obstacle - if it's part of the skeleton)
front slot (for hands/arms that appear in front)
Arrange the slot draw order in Spine so that slots render in the correct sequence. Slots higher in the draw order list render on top of those below.
Place your character's body attachments in the back slot and hand/arm attachments in the front slot.
For External Objects (Trees)
Since your tree is a separate world object and not part of the character skeleton, you'll need a different approach:
Split your character into multiple SpineSprite nodes - one for the back layer and one for the front layer, using the same skeleton data but with different skins or by showing/hiding specific slots.
Use Godot's rendering layers: Position your tree node between the two character sprite nodes in the scene tree, or use CanvasItem z-index and y-sort properties to control rendering order.
Alternatively, include the obstacle in your character's skeleton as a separate slot at the appropriate draw order position. This gives you full control over what renders in front vs behind.
Note about SpineSlotNode: SpineSlotNode is designed to insert Godot nodes into a SpineSprite's draw order, with children rendering on top of the slot's attachment. However, it won't help with external objects like trees since those need to be positioned between different slots of your skeleton, not within a single slot.
The cleanest solution is to organize your skeleton's slots properly in Spine to separate foreground and background elements.