Hello everyone, I would like to do this (red : player, blue : tree trunk to collide with, red, tree trunk collider collision limit, black : tiles) :

This is a 2D unity game using tilemaps (Unity version 2019.4.14).
The main goal is for the player to walk in front of the trunk if it comes from below and behind if it comes from above.
Here is what I tried :
I have a Polygon2DCollider on the player and tried to add a small Box2DCollider for this specific use (not necessarily the best idea …).
I can move layers sorting order dynamically in C# and even select the player collider when the collision occurs, but I am not sure how to detect whether the contact points come from above or below.
I generated custom Physics shapes on the tilemap sprite editor to match the tree trunk shape, but can change to a smaller one like the green line on the attached image.
If someone’s got an easier solution I am really up for it.
Thanks a lot for reading ![]()