Camera offset for mouse position with rotating camera?

anchorsonanchorson Member Posts: 15
edited March 2012 in Working with GS (Mac)
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.

Comments

  • old_kipperold_kipper Member Posts: 1,420
    This might not be very useful, but by having a rotating camera in a static position and centrally placed in the scene, and passing the actors through the camera view I managed to something with a similar effect. It also allows you to do a hud display pretty easily by rotating with offset any objects you want to hold in frame. I have also done a variation with enveloping of movement of the camera to add inertia effects to movement based on proximity to the centre point and speed of travel of the object .
  • anchorsonanchorson Member Posts: 15
    Thank you old kipper but it is quite a hustle to pass the objects through the view. Yet I wouldn't mind that if it would solve my problem..
    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.

  • old_kipperold_kipper Member Posts: 1,420
    Thought it wouldn't help much. My game is touch free and based on rotation and device inertia so most of the logic is based around accelerometers. Perhaps try contacting Gamesmold as he has also done a lot with cameras and rotation. good luck. kipper
  • anchorsonanchorson Member Posts: 15
    Thank you for your suggestion. Will contact Gamesmold, although i don't think he will respond because from my personal experience I can say people in GS community rarely answer questions that come via pm. But thanks anyway.
  • old_kipperold_kipper Member Posts: 1,420
Sign In or Register to comment.