Suggestion/Discussion - Structured Objects (Parent/Child)


Disclaimer: I have very little developer experience, so I’m not even sure if this is possible with the way GDevelop works.

I’m currently working on a medium sized project, and have had some thoughts about ways which could make the project more efficient for organisation within the editor itself. One of those thoughts, would be to have the ability to structure objects, similar in the way that variable structures are currently made. I’ve seen a few forum posts requesting or asking how-to make parent/child relationships between objects, but the solutions can be unintuitive compared to what many other engines offer out-of-the-box in their own editors.

The idea is that this could allow a parent object to have one or more child objects which would remain pinned to the position and rotation of the parent. Currently, pinning objects is a manual process done usually through multiple events, which can become cumbersome if required on many objects.

For example I have an external layout for my player object. This includes an object for control and collision detection (hitbox sprite), an object for animations, weapon sprites, and others (trail sprites, shadow sprites) etc which all follow the player object.

Currently, I need to have events that updates the position of all these objects every frame to follow the hitbox object.

Additionally, all these sprites take up a large portion of space in the scene editor, and when each main object, like enemies, NPC’s etc have multiple objects associated with them, it can make the scene editor very cluttered. I do use tags to filter objects, but this is a manual process of assigning tags to every single object created, and like all manual processes, can be prone to error.

An idea I have had, is to make children of a structured object be hidden, unless uncollapsed by a ui-button, like the mock-up I have made below.


TLDR Proposal:

  • Ability to make an object into a structured object, similar to a variable structure
  • Child objects inherit positional data from their parent, and can be offset in the editor
  • Have child objects hidden/viewable via a toggle to help with organisation
  • Can avoid cluttering eventsheets with events that pin objects to another

I would love to hear thoughts, ideas on this, and whether or not it is something worth investigating further, or if I should just keep quiet :slight_smile:


There are two things.

  • If we create the option in object editor/objects list, object will be parenting forever. (No possibility to separate them with actions )
  • Add a button in properties panel for setup the parent on each child instance. The fact to add the button in properties panel allow to user to keep the possibility to separate or parent them by actions.

Also on your mockup i understand something like group/folder in objects list, not a parenting system :confused:

Parenting system is important and i guess not a very hard work to implement, but we need keep the possibility to link parent/child in the scene editor between instances.
And keep possibility to manage the instances in eventsheet.
Problem is how identificate one instance ? (maybe we need a specific GUID for each or a specific name given in property panel for the parent and child?)

In some engines, this is how you can “naturally” parent objects with no effort. It is a group indeed but it is also means the root object is the parent of the child and when you create the root you also automatically create the child and when you rotate and move the root you also automatically rotate and move the child with it with no extra steps required on your part.

In other engines the group is not permanent, you can move childs out of the group, delete them and even add new childs if you desire. So we would need events like:

  • Get number of childs of an object
  • Check if instance of certain child is present for selected object
  • Pick certain child of selected object and delete, separate from root
  • Add new instance of certain child to selected object (it doesn’t need to be grouped initially, you can do it also at runtime, select any instance and add them as child of any object)
  • Check if selected object has root (parent)
  • Pick root (parent) of selected object

With the usual events maybe? If object is in collision with player, check if object has child if object has child pick all of them or the firs one, last one, the one is in collision with player and then delete, move out of group…etc Then pick any instance as usual and say add this instance as child to this object. This is how I could imagine it.
We already have linking events in GD it should be not that difficult.

I was thinking about it since a long time. I think it is possible. The problem (like Bouh said) is how to access them. While we could do something like Object1.SubObject1, this would require core modifications, I think. IMO, the best way, I am not sure if it requires a core modification, would be to add to objects an expression getChild(string).

Except maybe for that, the rest should be easy. Adding to runtimeObject a _child attribute Wich is a Hashtable for mapping String(childName) to Object(RuntimeObject or extended from it instance). For rendering I think PIXI has a convenient addChild method on Renderer objects. This would still require some changes in the Renderer to support those structured objects.

1 Like

I could imagine similar to structures ObjectName[“ChildName”]
Then I think we should be able to use the normal events to be even more specific.

If player is in collision with ObjectName[“ChildName”] and the Animation number of ObjectName[“ChildName”] = 1 then Delete ObjectName[“ChildName”]

If player is in collision with ObjectName then Add ObjectName as child to OtherObjectName…etc

And we could also have methods like you mentioned to getChildCount() getFirstChild() getAllChild()…etc.