# Parent-Child system

I’m trying to make a parent-child system in GDevApp, in GDevelop I can use points to make such thing, but in GDevApp I can’t add custom points to objects at the moment so I’m trying to use math to calculate child position compared to parent object. But I have problem with the calculation when the parent object start rotating. The child object should follow the movement and rotation of parent object. I can solve movement (left, right, up, down) on X and Y axis, but I have trouble with the rotation because when the parent start rotating, I’m not sure how to calculate the new position of child object on X and Y compared to rotation (Direction, Angle) of the parent.

I just made an example in GDevelop of what I’m trying to make in GDevApp:

Anybody could help me with this?
Actually, if 4ian could share/explain how position of custom points are calculated in GDevelop, would be great as probably I need similar calculation.

Thanks.

Computing the points position implies using cos and sin functions. The exact formula, knowing that a point is at position X;Y and the angle is Angle, is:

```NewX = cos(Angle)*X - sin(Angle)*Y NewY = sin(Angle)*X + cos(Angle)*Y```

So in your case, X;Y would be the position of the child relative to the parent, NewX and NewY will be the position of the child relative to the parent, and Angle is the angle of the parent. If you want to position the child:

```ChildX = cos(Angle)*X - sin(Angle)*Y + Parent.X() ChildY = sin(Angle)*X + cos(Angle)*Y + Parent.Y()```

Hope it helps Sorry for the delay! Let me know if you still struggle with it.

Thanks 4ian I’m getting closer, but it still not perfect, maybe I don’t get it how should I use this formula The child object orbit around the parent object too fast like planets around the sun which is cool, but it not something I want. If the child object is on the right side of the parent, it should stay there wherever the parent is rotating and move, the child always should stay on the right side of the parent.
But instead it orbit around the parent gdevapp.com/play.html?g=54a55b7 … 42999b7846

This is the way I use it:

[code]At the beginning
child.Variable(distanceX) = parent.X() - child.X()
child.Variable(distanceY) = parent.Y() - child.Y()

X position of child:
cos(parent.Angle())*child.Variable(distanceX) - sin(parent.Angle())*child.Variable(distanceY) + parent.X()

Y position of child:
sin(parent.Angle())*child.Variable(distanceX) + cos(parent.Angle())*child.Variable(distanceY) + parent.Y()

Angle of child:
parent.Angle()[/code]

2 things:

First, cos and sin are using radians and Angle() returns degrees, so you have to add ToRad to each parameter of cos or sin:
Second, in fact, I just realized that there is already a function that do all the calculations for you. It’s “Put an object around a position” (or around an object). It’s an action specifically designed for this purpose, so better use it Thanks Anyway, using this formula the parent-child system almost worked a minute ago, but there was a little bit of excursion in the position of the child when the parent was rotating to the left, I was thinking it because it using the origin point or something so I tried to use PointX(Center) and PointY(Center) instead X and Y, but made it worse, now even with X and Y doesn’t work But I don’t remember I have changed anything other than X and Y to PointX and PointY Maybe I overlook something, don’t know I guess I’m going to wait for points to be released in GDevApp 