How to make an object parent to another?

It is easy if you know ‘who are the objects’, you only need one event and two actions: first action copy to the child object the position of the parent object, and second action copy the direction.
Game Develop has two basic sprite points: ‘Origin’ and ‘Centre’, ‘Origin’ is the real object’s position, and ‘Centre’ is over the sprite is rotated.

In your parent object, you put the ‘Origin’ and ‘Centre’ points where you like. But you have to add a point (i.e. ‘Child1’) and put it where the child object must be.
In your child object, you don’t add any point, but you have to put the ‘Origin’ and ‘Centre’ points in the same place, because if the ‘Centre’ is not in the same position of ‘Origin’ the rotation will be degenerated, not the same of the parent object, here is an image to explain:

Points.PNG
Where:
Blue point is the ‘Origin’
Red point is the ‘Centre’
Green point is the ‘Child1’
Note that in the child, pink object, the ‘Origin’ and ‘Centre’ are in the same place.

Now you add this event:

Always: ........Do = Parent.PointX(Child1) and = Parent.PointY(Child1) to the position of the object Child ........Do = Parent.Direction() to the direction of Child

1 Like