Camera offset for mouse position with rotating camera?
I have a scene with size 2400x1600. And want my actor to move towards the mouse or touch even when the camera moves (scrolls). So i used a normal camera offset (adding camera origin to mouse position). But when the camera rotates that won't work. So I came up with a very long function, a type of rotational offset for mouse position;
Mouse Position X =
game.Camera.Origin.X +(magnitude( game.Mouse.Position.X , game.Mouse.Position.Y )*cos(vectorToAngle( game.Mouse.Position.X , game.Mouse.Position.Y )- game.Camera.Rotation ))
Now that function, if my calculations are right (Dr.Emmet Brown :P ) , should give the position of mouse relative to the origin of the "display". But when i use it with Acceleration Towards, the actor accelerates to top right of the display.
If anyone could bother to check that calculation I'd be glad.
I can provide a project file if anyone is interested.
Please help me! My game might survive without that kind of offset but I just cannot admit defeat !
Thanks in advance.
Mouse Position X =
game.Camera.Origin.X +(magnitude( game.Mouse.Position.X , game.Mouse.Position.Y )*cos(vectorToAngle( game.Mouse.Position.X , game.Mouse.Position.Y )- game.Camera.Rotation ))
Now that function, if my calculations are right (Dr.Emmet Brown :P ) , should give the position of mouse relative to the origin of the "display". But when i use it with Acceleration Towards, the actor accelerates to top right of the display.
If anyone could bother to check that calculation I'd be glad.
I can provide a project file if anyone is interested.
Please help me! My game might survive without that kind of offset but I just cannot admit defeat !
Thanks in advance.
Comments
Anyway, I'd like to take that chance to restate the problem if it is not clear for others.
What i want is to get the position of the touch, relative to the origin of the display (not the camera origin), while the camera is both scrolling and rotating.
http://www.gamesmold.com/contact.php