how to y or z sort

Not favoritedFavorited Favorited 0 favourites
  • 5 posts
From the Asset Store
A master sorting Puzzle fun and addictive puzzle game! A challenging yet relaxing game to exercise your brain!
  • in my game theres just one object and i want the player to go behind it and in front of it whenever its lower then its why. i cant do it for some reason. please help

  • 1 object?

    you could have 3 layers.

    0 if the object

    1 is the player

    2 is the object again overlapping.

    then have the y coordinate of the object. when the player y is larger. hide layer 2

    so you are over the object

    when y is smaller. hide layer 0. so you are behind the object

    you could have a small hitbox at the bottom of the item. so you cant walk through it but high up you can walk behind it

    hope that makes sense

  • If both objects are on the same layer, you can do an easy Z sort by adding all of the objects into a family, and then using an ordered For Each loop to make them appear on top of each other:

    For Each ZOrderFam

    (ascending)

    ZOrderFam.y

    Move to top of layer

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • can you specify some more i dont know construct 2 that well so.

  • In the Project Bar there should be a Families folder, create a new family consisting of your Player and Object (assuming they are both the same object type, which I'm assuming is Sprites) and then name it whatever you want (i'll refer to it as ZOrderFam)

    Then in the event sheet add an "ordered For Each" loop that runs every tick. Setting it to go through each object in the family in Ascending order by their Y value will make the actions start with the uppermost object and end with the lowermost one. Then adding the "Move to top of Layer" action will sort them and make the lower object appear in front of it.

    (side note this was in Construct 3 rather than 2 so there may be some differences between them but I'm pretty sure 2 has all the features I used in this example)

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