GDevelop icon indicating copy to clipboard operation
GDevelop copied to clipboard

Fetching the highest active Z-order of objects in the scene.

Open VanCastar opened this issue 2 years ago • 3 comments

Description We need to have a function to fetch the highest Z-order value in the scene.

Many times in our games we've been needing to get know the highest Z-order value of current objects in the scene to determine some effects accurate and correct placement in the Z-order list.

  • We are forced either to keep track with a variables every time when creating an object in the events to keep track of the highest Z-order value.
  • Or to scan through every object to determine the highest object Z-order value (really heavy to do every single frame).
  • Or create an dummy object and getting it's value and store it in a variable to use on the next event every time we need to know the highest value.

Solution Since creating new objects in the events, the engine already knows the highest Z-order value and makes the new object to have the highest Z-order value when creating a new object.

It would be immensely helpful to be able to call the highest Z-order value with one function to use when needed.

VanCastar avatar Sep 14 '22 16:09 VanCastar

It seems that the incrementing does appear only in the Editor, and in runtaime the objects are created at the set z-order and the fetch command is already implemented. Though imho as quite misleading name of LayerDefaultZOrder()

Closing this issue as moot for now...

Except it doesn't do that at all...

Okay way too confused on this thing. I can't figure out what LayerDefalutOrder() actually does do...

And the original issue of how to determine the highest value of Z-order of all object in the scene still prevails.

VanCastar avatar Sep 14 '22 17:09 VanCastar

Hello ! So maybe what you really want is something to get a list of all object instances in the scene ? That way you can code-it-yourself ? Or do you really want a specific action/condition for that ?

Oxey405 avatar Sep 15 '22 16:09 Oxey405

Hello ! So maybe what you really want is something to get a list of all object instances in the scene ? That way you can code-it-yourself ? Or do you really want a specific action/condition for that ?

Nope, I would need the highest Z-order number on the scene, not a list of all objects.

VanCastar avatar Sep 16 '22 08:09 VanCastar

I had a look: the default Z order of a layer corresponds to the highest Z-order value of every object on that layer, at the beginning of the scene. It doesn't change afterwards when creating objects on that layer. You can set it though with the adequate action.

So yeah, it's confusing.

An expression to get the highest Z-order value could be useful indeed!

AlexandreSi avatar Sep 28 '22 16:09 AlexandreSi

Sorry but the fix I found was introducing an inconsistency so I reverted my change in #4359.

We'll work on it to see if there's a sustainable solution that doesn't require too much computation.

AlexandreSi avatar Oct 05 '22 15:10 AlexandreSi