How do I hide character sprite behind wall?

0 favourites
  • 7 posts
From the Asset Store
Be discreet and rescue your friends from behind enemy lines.
  • First of all i am total newbie in game development. May be there is many topics about this but i could not find anything that i found helpfull. Everything is fine from front but when character walks behind the wall i can see him through. Is there easy way to fix this?

  • Hey Matov hi.

    Of course you can.

    First solution is to make the z-index of your player lower than the walls z-index(right click to wall and sent to front or edit the z-index) .

    Second solution is to make a new layer with the walls that you want your player to be behind and put above the layer that you have your player.

    Cheers.

  • So you can only do one or another option? i mean you cant get behind a wall that you put to bottom and you cant get to front of a wall that you put to top of the layer. But i wanted to know is that possible to be invisible behind a wall and be visible in front of it? Like in old isometric 2d games

  • So you can only do one or another option? i mean you cant get behind a wall that you put to bottom and you cant get to front of a wall that you put to top of the layer. But i wanted to know is that possible to be invisible behind a wall and be visible in front of it? Like in old isometric 2d games

    It's quite easy.

    Compare the y-component of your sprite against the wall's y-component and set the z-index accordingly.

  • Hey

    Alright forget about the z-index i will just give you a straight example how to do this without the need to mess around with the z-index and the action of add another layer .But keep in mind if you are a complete newbie as you say, you have to read the manual to understand the meaning of the z-index and stuff like that.

    Here you go.

    http://www.filedropper.com/hidesprite

    I didn't want to mess around with overlaping etc. so i just add a simple variable to the wall sprite. (Move the keyboard arrows.)

    Cheers.

    Edit : i just read that you need this action for isometric 2d style game.So i think zenox98 way its "the way" to do it.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Oh, i could not open file because its 218 version while i have 216. I also tried Zenox98's way and its wonderfully works on one sprite but when i want to add family or tilemap its not working.

  • after some time i tried to create new foreground layer and started to paint tilemap on it that will hide character to create depth effect but its not an ideal solution because i had to increase collision box of walls and now its become not very realistic.

    if someone has suggestion on tilemap z ordering i will be gratefull.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)