Problem with rotating around a node

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Tomi


I would like create a node around an other, rotatable node. I know the direction and distance (e.g.: 50 pixels) and I would like the XY coordinates on basis of these.
This is the piece of code in player1 node:


I have similar problem like this:
but I can’t set the center of rotation to player1 positions. So, the player2 always orbits around itself but I would like similar a bullet creating at the cannon barrel or a planet around a star.

:bust_in_silhouette: Reply From: magicalogic

Use a position2d node as the root of your scene instead(This will serve as the origin of the scene). Add your player giving them the offset you need from the origin. Now when you rotate the scene it will rotate around the desired origin.

Thanks, Magicalogic, but I would like avoid using of Position2D node if possible and use some calculations instead of that, because the size of sprite may be different, which emit this other node.

Tomi | 2021-06-10 18:41