I'm making a game about two ghosts, and an important thing that I want to add is the possibility to pass through walls. I have managed to make the passable behaviour and everything.

Next, I need to change the Tilemap's Order in Layer number. That's because I want to add some things inside the Tilemap that should be shown until player passes the wall. The way I though of to do this is to decrease the tilemap's layer order when the player is inside it, and put it back to the previous value when player exits.

  • \$\begingroup\$ Have you tried Renderer.sortingOrder ? \$\endgroup\$
    – DMGregory
    Sep 24 '20 at 14:56
  • \$\begingroup\$ Yes i found it already. Thanks, my problem is solved \$\endgroup\$ Sep 24 '20 at 15:14
  • \$\begingroup\$ Glad to hear you've solved your problem! Want to write up your solution as an Answer below that you can mark as Accepted? This can help future users, and also earn you some reputation from folks who find your answer useful. \$\endgroup\$
    – DMGregory
    Sep 24 '20 at 15:17
  • \$\begingroup\$ Please post that as an Answer below, not as a comment. \$\endgroup\$
    – DMGregory
    Sep 26 '20 at 0:33
  • \$\begingroup\$ yeah hah i'm new using StackOverFlow sorry \$\endgroup\$ Sep 26 '20 at 0:34

I solved my problem with GetComponent<TilemapRenderer>().sortingOrder = x;

  • 2
    \$\begingroup\$ This answer would benefit from showing more code... \$\endgroup\$
    – Vaillancourt
    Sep 26 '20 at 10:46
  • \$\begingroup\$ There is a way to do that like the classic rectangle only for code? i don't know the name of that feature, but i hope you understand \$\endgroup\$ Sep 27 '20 at 15:50
  • 1
    \$\begingroup\$ Yes, you write the code and you hit "code sample" in the top edit bar. If you have trouble, someone else will fix the formatting. The idea here is that you show us a bit more how and where you use the line you posted. Please use the edit feature below the Answer text. \$\endgroup\$
    – Vaillancourt
    Sep 27 '20 at 17:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.