[SOLVED] Get Layer from an object

I have a function that needs to create a sprite on the same layer as another sprite I pass through as a parameter. How do I do that? As far as I can tell, I cannot programmatically determine the layer that any given sprite is on?

I’m fairly sure you can compare the layer of an object.

There is an Object.Layer() expression.

You can find a list of the expressions here: Expressions reference [GDevelop wiki]

1 Like

Thanks, it wasn’t obvious that Object.Layer() existed because the Layer field in the Create object dialog doesn’t seem to expand available methods like others do, it only seems to want to take a string. However, I just tested it, and Object.Layer() does work.

2 Likes