edited June 2014 in ORK Support
Hello guys! :)
Sorry if it is a non-related ORK question, but maybe someone could help me... I'm building a 2d game with a tilemap, different layers for ground, walls, root. But i have a problem: when the player is under a root, or discovering a secret passage, i would like the above tiles to disappear (even move them to deepest would be fine).
Anyone cold suggest a way to achieve this, maybe attaching a script to objects? Thanks in advance, have a nice day!

Kae

PS: i'm using Unity Free, so no pro features here. ^_^
  • Your doing top-down 2d right? I had major headaches with that.

    One way would be to manage sorting layers(this requires some coding).

    another would be to use your z axis. so basically put the background way far behind and whenever you want something in front of another pull or push it on z it will "force" sorting it's literally the easiest way


    There's also what I was planning for isometric but might overcomplicate things or could give you other ideas:

    So, another way would to use 2 different angles for your 2d. Put the "ground" sprites flat on x/z facing up at y axis.
    and then put the all the characters and props(rocks, walls trees, items, etc) which you can walk in front and behind on a different angle at 90deg.(on x) facing z axis. so you can actually fake depth this way without having to code any layer sorting.

    So next, use 2 orthographic cameras. Use one ortho camera as your background(ground) layer and use your second ortho camera as your character/prop layer. make sure you remove one of the extra audio listeners.

    then use clear flags and culling mask to sort the cameras. So in Layers(top right of camera inspector or edit>project settings>tags&layers) and make 2 layers. One for your background camera and another for the "everything else" camera.

    Then go to your background camera and set clear flags to solid color or skybox, whichever you want most and set its culling mask to only have the layer you cretaed for the background checked> easiest way is to click nothing then click the layer for the backgorund*make sure its the only checked one.

    then on the "everything else"/charcter/prop camera set clear flags to "depth only" and in culling mask make sure everything is checked except the background layer. Now both cameras will render the 2 scenes together automagically.

    As far as how to make sure to keep your character always at the right depth its the same principle as the first option I wrote all the way at the top. You'll have to use z to pop one character in front of the other so thats what I mean by it might overcomplicate things. But if your using isometric this was the only way I could manage certain things.

    Well I hope any option helped you if you need more details I'll be back tomorow unless someone else posts some tricks



  • Thanks for the explanation SteveS! I really appreciated it! ^_^

    However, i did a simple, effective, thing... I just used on trigger enter/exit! Having an orto camera, i just played with colliders and it worked perfectly. I had suggestion from an Unity Answer, it is incredibles how things can be easy sometimes! :D
  • That's a good Idea! See I went all around without ever even thinking of that.. so simple.
    I love thinking about this stuff but tend to go overboard ;) Glad you got a solution
Sign In or Register to comment.