Object Created Function (SOLVED)

So I’m trying to make a function where it checks if an object has been created, but I don’t have a good understanding of creating functions and extensions in GDevelop and need some assistance on figuring out how to do it

Thank you in advance!

Make a behavior. Add a boolean property JustCreated and set default as true. Click the three dots next to the property and „generate expression and action“. Now add the lifecycle method doPostEvents and change that property there to false. Attach that behavior to your object.

Now you have a condition, that picks all objects which you created during that frame (only those which are above your condition in your event sheet).

You could also pick the created objects with the „create object“ action… its kinda redundant to implement a condition, which is already build-in.

What are you trying to do?

1 Like

I have this object which contains several sprites in it and I was hoping to make it so where it changes to a random sprite each time an instance is created and I couldn’t really find anything in the event sheet to solve my problem so I just resorted to trying to make a function

Is each sprite an animation?
Then set animation to Random(n) after creating the object.

Is it a custom object that holds multiple child sprites?
Then use the OnCreated lifecycle method and create/delete child objects in there (using a variable and Random(n) to pick corresponding children)

It is a regular sprite object with around 11 Animations

Thank you so much, I managed to get it to work!