I have been trying to find a way to create a parent-child structure for objects, particularly instances of objects, where if the parent moves, the children automatically update their positions to maintain their relative location to the parent (behaving very similarly to the 3D animation concept). I tried linking objects, but found out I still need to code the positional updates. I have assigned objects to the desired parent points every frame, but I was wondering if there was anything I could do with an automatism to make it easier?
Thanks in advance!
No automatism for parenting.
This is the best I was able to come up with when I needed such thing:
drive.google.com/file/d/0B1sXiY … sp=sharing
Can be improved but works. When you open the project, in the scene editor you can add as many child objects as many you want and when you run preview all the child objects in the scene going to follow the movement and rotation of the parent object while maintaining relative position and also rotation.
Things that need to be improved depends on your needs:
-you can use parent object only one time in the scene, if you want more than one parent in the scene, possible solution could be to name each parent differently and it childs and you need to include the events for each parent in the scene.
-childs are maintaining relative rotation to parent which cause it, childs can’t be rotating if you want to rotate the childs, possible solution could be to use animation instead of actual rotation or delete the actions used to maintain rotation
- childs are maintaining relative position to parent which cause it, childs can’t be dragged and moved once they are parented
-childs can’t be created on the fly, childs need to be present at the beginning of the scene (added in the scene editor)
Not perfect, but I hope it helps to get started with creating parent-child structure.
Thank you for the help! I will review the file you created.
So it looks like the system would need to be coded then.
Perhaps the intention in GDevelop was that the game developer knows how to organize objects such that you can generalize code to apply to all objects of a specific type every frame. It just requires a different frame of mind than typical object-oriented coding allows.
I guess there are structure variables which contain numerical values or other variables, but not specific references to objects.
Nevertheless, it feels like parenting functionality might be a good feature to develop for the future, as it has a very natural feel when coding in the events editor.