I tried a lot but I couldn’t make a tree that the player can pass in front of it, behind it and also collide with it in the right place.
I’m working on 2D-rpg game (snes camera perspective).
I was able to make the player appear in front and behind the tree correctly using this code:
transform.position = new Vector3(transform.position.x, transform.position.y, transform.position.y/100);
I used it on the start of the tree and in the update of the player, so the tree would have its own Z and the player would appear in front of and behind the tree depending on the y position.
But changing this z position killed me to set a collision between them, so how can I do it?
PS: if there is another approach, it could be fine too, as long as it works ![]()