I try to work on a Force based 2D ship game. I have Forces, that a stored in a Dictionary, for 'Jets' on a ship. So I just have to say the name, the amplitude and let the engine do the acceleration/rotation.
For that I have to rotate the force into the local coordinates of the ship, before I can apply it, but instead only rotating the new force, it also rotates the force stored in the Dictionary. What causes the Force to spin around.
Force f1 = new Force();
f1 = Player.JetsDict["RearRight"];
f1.Position = Vector2.Transform(f1.Position, Matrix.CreateRotationZ(Player.Rotation));
while this code dose not change the instance stored in the dictionary (but I don't want to use it, as its longer, and I got many forces to handle):
Force f1 = new Force();
f1.Position = Player.JetsDict["RearRight"].Position;
f1.Vector = Player.JetsDict["RearRight"].Vector;
f1.Position = Vector2.Transform(f1.Position, Matrix.CreateRotationZ(Player.Rotation));
Why?
Greg the Mad