Object linking?

Hello everyone,

An object may spawn other objects and track them. For example, spawn explosives, store a reference to that object, then later use the reference to trigger the explosion.

In gdevelop, behaviour properties can not store object references. Function parameters can take object references, which can not be stored and used later, say in doStepPreEvents.

Object linking: " Take into account linked objects" itself requires a reference to the target object type, instead of simply providing a list of linked objects.

Am I overlooking something obvious or can we not create object hierarchies in gdevelop? And how do other developers overcome this?

I think I might be stupid but I think you should look into arrays and structures
What exactly are u trying to do? im really bad with reading descriptions im more of a visual person also so i may not exactly understand


I am trying to create an object in a behaviour and then modify that object later on. For now I just want one object to follow the position of another.

Using object variables as an id to link the objects together could work. You could use a global counter that increments every time a link is made to prevent duplicating ids.

You can link objects with a behavior. That’s how the spawner behavior tracks objects.

You can’t link instances of the same object to one another but you can create links between the object with the behavior to the object from an action. The action could be triggered when needed or it can trigger on every frame but the function could decide whether to spawn or link an object. The behavior needs an object in a parameter to be able to create the link.

You could probably use Javascript to avoid needing to use an action.

1 Like