I'm trying to make an entity system where the entity can have multiple components, like arms and legs, or weapon attachments, but I can't figure out how to get all of the components to stay in the right position when the entity is rotated.
With the code I currently have, the rotation works, but I can't place the components where they are supposed to be. When I try to place the component at the mouse position it doesn't go where it is supposed to, and rather seems to stick to a circle path.
Vector2 newPos = new Vector2(Base.X, Base.Y);
newPos.X += (float)(PositionRelativeToBase.X * Math.Cos(Rotation - MathHelper.ToRadians(PositionRelativeToBase.Y)));
newPos.Y += (float)(PositionRelativeToBase.X * Math.Sin(Rotation - MathHelper.ToRadians(PositionRelativeToBase.Y)));
This is code that I found elsewhere, though, so I don't understand it entirely, so I can't really explains my thoughts behind it.