Y based z-order request

0 favourites
  • 13 posts
From the Asset Store
Advanced inventory mechanics for your RPG game (Array-based). Take Items, split them, pick up them, read the description
  • Hello

    I'd like a feature, which enables me to set a family or objects z-index based on its current Y-axis.

    Like, every tick, it simply sets the z-order index to its Y-axis integer.

    Atm, I am using a single devoted for each loop on one family (Zorder) sorting it by Y, moving all the family objects to the top as it loops, giving me a nice fluid z-ordering of my dynamic and static objects all in 1 go.

    However, this thing alone sucks up a roughly ~9% of total cpu power usage on the profiler tab.

    Seeing as the rest of the game totals up to ~22%, I consider my z-order method to be a bit hoggish.

    I think that having something native in an object, which can simply set its z-order index to its Y-axis number every tick, could save quite some cpu. Perhaps a Z-order behaviour.

    This is not the first time I ran into this issue relating to z-ordering, and did not find a better approach, if there is a better method to do z-ordering, I'd love to hear it.

  • The method you have is fine, just don't run it every tick, run it once when they move.

  • The method you have is fine, just don't run it every tick, run it once when they move.

    The for each loop runs continously.

    I have, atm, just 10 ai's doing pathfinding to reach my character who moves around in an isomteric like enviroment, about 100 trees instances (several frames with different trees) , 200 or so bushes instances (also with frames for different bushes).

    the Ais move about all the time, so the loop needs to run more often.

    edit:

    the zorder boolean check makes sure dead bodies laying around get ommitted.

  • Its a visual effect, so it stands you can filter it down a bit more by using "is on screen".

  • Its a visual effect, so it stands you can filter it down a bit more by using "is on screen".

    When I read it, I thought, brilliant !!

    Then, after applying, it gave a ~1% imrpovement, .... when the player stands still (screen is following player)

    I am thinking that an option to continously set a Z index integer, based on an objects Y value, could be a lot faster.

    And likely such a feature would only be rendered on the visible on screen elements.

    Still thanks for the suggestion newt

  • Checking every tick makes little sense as we barely even register frame changes at 60fps.

    Likewise checking every tick while something is moving makes even less, as it only needs to change z order if it gets a new y coordinate.

  • Checking every tick makes little sense as we barely even register frame changes at 60fps.

    Likewise checking every tick while something is moving makes even less, as it only needs to change z order if it gets a new y coordinate.

    Ohw I did not use an event like every tick, but I meant, the for each event, has that green circulair arrow, making it go continously (like every tick if possible )

    As it is, it's intended for the scirra arcade, fullscreen web, and mobile devices.

    Here is a quick dev export for html5 web

    no audio yet though

  • So I have been getting my freak on with the multiplayer functionality, and made quite some steps..

    Sadly the topic of the post at hand strikes again -,-

    I distilled it down to a loop for zordering having lots of the same instances on a layout.

    Meaning: a dedicated loop, with lots of instances from the same object, placing all objects at the top, kills performance for me. (yes with on screen)

    I think it has to do with the move to top and or move to bottom action being repetitive executed.

    I believe with an automated z-index placement derived from the Y position (or X for horizontal based) could save a load of performance here.

    I have isometric levels with lots of things making up walls and scenery, these all stuffed in a family with the player object, and loop through it placing everything on top based on a Y based loop order.

    The ordering gives a very clean effect when you walk about through layouts being infront and behind objects.

    My latest game in the arcade, Skeleton slayer 2 uses this technique, and you can see the effects walking about around trees and what not, looks really pretty and not bad performance. Most of the performance is actually from the zordering

    BUT BUT BUT ...

    I been adapting that version for a multiplayer version, and as soon as the zorder loops runs at the same time the loops updating the multiplayer objects runs, my performance drops dramatically

    If I run either, the multiplayer loops, or the zordering loops, alone, they run well, but together, unplayable.

    So, here is the request again:

    Please add a true/false propperty for objects on layouts to set their Zordering based on the Y axis. (descending: lower Y positions are at the top; in effect, the further upward on the layout (lowest Y = on top, highest Y is on bottom)

    I am guessing it could greatly improve zordering for isometric games. (as it would no longer require a dedicated loop handling ALL level objects every loop)

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a plugin called ''z sorter'' it do what you are looking for and in my opinion it's a very well made plugin with minimal use o CPU

  • While somewhat hacky,

    The way i use layers may be suit your game.

    The game i'm making has a base grid of 64x64 px. It's isometric so i have to have a efficient z ordering system.

    This only works if all your objects have a base the can be divided by itself. For example units use a base of 1x1, walls 2x2, big buildings 3x3 etc etc.

    I translate the layout angle to itself -45, thus giving the feeling of 'isometric'.

    So if the base grid is 1x1(*32px), and say the width and the height of the world is 50x50. Then i have 99 layers in game.

    For static objects, on.created move to layer int(object.x/32 + object.y/32).

    For moving objects, such as player or monsters, for each object, move to layer int(object.x/32,object.y/32)

    If your game is using a normal angle, then you can simple add 1 layer per y height / base tile.

    So now on create move to layer int(object.y/32) ` same with every tick.

    In game this works really well.

    However the downside to this is when debugging. The debugger will be checking every layer, so its runs at a crawl.

    I hope i explained it well. I can post a screenshot of how it works if you need.

    Best of luck,

    Tom

    For static objects

  • There is a plugin called ''z sorter'' it do what you are looking for and in my opinion it's a very well made plugin with minimal use o CPU

    The plugin link:

  • Guif0DA, thanks, I took a look at it and its perfect, thanks.

    tomsstudio, sounds like a nice approach, though, I have many different shapes in objects, and animations, making them square would mean gobbling up way more memory space then needed. I will play with it though, I had not seen that approach yet.

    rexrainbow, awesome plugin !!! its so much more efficient then the zbased for each. Especially when you have a lot of instances of the same object occurring.

    Scirra, what Rex made works very well, any chance of implementing something like that so it can be used in the arcade too ?

  • Guif0DA, tomsstudio, rexrainbow, Scirra,

    I made a crude demo of my game I wanted to use for the 2030 comp, dont think I have enough time to finish it though.

    The multiplayer bit works, the current demo is intended as abit of co-op, fight against the enemies in the game.

    Max 5 players, and there will be max 5 enemies at any given time.

    The enemies AI is a bit primitive, still working on that, and there is no real end goal.

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