I am writing a camera script for a RTS game. Currently it can orbit and zoom around a point. The target point. I want the player to be able to ‘pan’ around by moving the mouse onscreen. The mouse movements on screen will then be used to translate this target point.
Currently I can get the vector from the users screen from where the first click (the new origin).
if(Input.GetMouseButtonDown(0)) {
dragOrigin = Input.mousePosition;
}
Vector3 pos = Camera.main.ScreenToViewportPoint(Input.mousePosition - dragOrigin);
Vector3 move = new Vector3(-pos.x * 2.0F, 0, -pos.y * 2.0F);
How can I translate the current point
Vector3 target = (0.0F, 0.0F, 0.0F);
Taking into account the rotation my camera is angled at, say 30 degrees. This is only for the X and Z coords. The Y is always 0.0F in this context.