How to Group 2 Objects?

Hey all,
How can I pair two objects together, so that they are directly centered and on top of one another, but I can add different events/conditions to each?

Hiya,

Use the grid and place them into position, then set the events for them as normal.

As far as I know, there’s no way to group objects and move them around on the scene together the way you can with shapes/text in programs like Word, Publisher, Excel, etc. You can select multiple objects and move them together, but it’s not like you can right click on the objects and “group” or “ungroup”.

1 Like

Is it possible to place them on top of each other using position events? Can I place object #1’s center on object #2 and have them move together

you could set the center of both to the same coordinates and as they are different objects they will respond to different events. Maybe you could use joints at the beginning and then delete joint when you want to move separately

1 Like

@thebestpichu Hi. You can currently only parent objects at runtime (that is when the game is playing)

Apart from the suggested “joints” method (using the Physics system 2.0) you can use two additional methods:

  1. Using the actions under: Common actions for all objects / Position / Position of an Object and make object 1 be always on top of object two.
  • To properly fill in the position fields you have to use the expressions in the form of Object2.X() / Object2.Y() and that way the Object#1 will be located wherever you put the origin point for both objects w/ sprites.
  • If you use a custom point you can use the expressions in the form of Object2.PointX("CustomPointName") / Object2.PointY("CustomPointName")
  1. Using the “Link Objects” conditions / actions. These are events designed to create a virtual connection, an advanced form of parenting, however just linking a pair of objects won’t be enough, after the link is established you have to act upon the condition that the objects are linked to do something.
  • At first it might seem redundant with option one but it can allow you subtler interactions as seem in this example: GDevelop 5
  • For more info on the Link Object events please read the manual page here: Link events [GDevelop wiki]
3 Likes