Keeping player's order to front

This forum is currently in read-only mode.
From the Asset Store
Players follower. use it for anything which follows the player
  • This is probably another embarrassingly easy question, but I've tried to fix this for an hour to no luck.

    Here is the problem. I have the player and all other sprites all on the same layer. They need to be on the same layer because sometimes the player will appear behind trees/walls and other times in front of them. I have the event logic to handle that. What is not working is the stupid ground tiles are appearing above the player. I can't send the tiles to the back because of the way I have setup the layout, it would be a pain to fix. I've tried everything I can think of.. putting the ground sprites in a family and then saying "send player to front of family".. doesn't work. That actually made it worse and made him appear behind some of the tiles!!

    I also tried a simple send player to front at the start of the layout, but I have a feeling that that only sends him to the front of the current tile he is on.

    What is an easy way to get the player to always appear in front? ... with of course the ability like I am doing to put him behind trees and stuff like i'm doing.

  • when zorder changes reset the order for all sprites to what you want. how is it set up in the layout

  • I don't think I can automatically reset all sprites. The reason is because of the tileset

    I'm using. To give the appearane of 3d the tiles can interlock with any others. So some water, or grass sprites for example, will be lower z order than others.

    If I was to automatically reset them there would be no way to know which water sprites would go ontop

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Why don't you just use separate layers? One for the ground and background, one for the player, then one for the foreground.

  • player is overlapping floor: place floor behind player

  • store zorder in pvariable at startup when player changes zorder reset the objects to keep their orders. so when player is sent to front the privable still has original order so you can use for each ordered by pvariable on family and send player to front last

  • I finally got this to work. Thanks for all of the input guys. I swear there is some weird intermittent bugs that were making this harder, or I just was working on it too long. For example, you would think that the following would place the player in front of the ground:

    If Player overlapping ground

    • Place in front of floor

    That actually put the player behind the floor!!

    Separate layers wasn't an option because for example the same tree had to appear behind or in front of the player depending on if the player approached the tree from the top or bottom.

    A side effect of what I was doing before was causing the order of the player to move behind the floor. The new solution doesn't have that problem. Placing the floor beneath the player didn't work in the earlier case.. it ended up causing this crazy rippling effect in the tiles.. pretty cool actually.

    So what ended up working was:

    I changed all of the trees, walls, rocks to sprites.... left the floor as tile background. Put each in families, terrain and floor. Then..

    ---------------------------------------------

    Start of layout: Send player to front

    If player overlapping at offset (0,100) place player behind terrain

    Else Send player to front

    ----------------------------------------------

    No other combination worked... so simple I'm kicking myself

  • Post a cap, there's a number of ways to deal with this, but without knowing exactly what your doing its pretty hard to tell you what to do.

  • It's working now, but if I run into complex problems like this in the future I'll post a cap. Should save a lot of confusion! Thanks again for all of the replies!

  • you could always do something like this, makes it easy

    http://files.getdropbox.com/u/1024727/ordering.cap

  • awesome!! That's really cool. Nice graphics too.

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