Sprites rendered in the wrong order


I’m using sprites in a 3D world and I have this bug when two sprites are too close :


I read it’s a common bug and I should use “sorting layer”…

But I can’t, when the man goes behind the tree I don’t want to see him in front…

What could I do to make it work ?

Use the sorting layer (or order in layer), and change it in code as necessary depending on the position.