Hi!
I have next camera system set up:
CameraPivot game object that has position 0,0,0 in world
MainCamera is a child of CameraPivot that has certain position and rotation. Camera is orthographic.
I have next script for controlling camera:
private void Update()
{
MoveCamera();
}
private void OnCameraZoom(float amount)
{
MainCamera.orthographicSize = Mathf.Clamp(MainCamera.orthographicSize - amount * Time.deltaTime, minZoom, maxZoom);
}
private void OnCameraRotation(float side)
{
iTween.RotateBy(pivot, iTween.Hash("y", yAxisRotationMultiplier * side, "space", "world", "easetype", easeType, "time", rotationTime));
}
private void OnCameraMovement(Vector2 axis)
{
movementInput = axis;
}
private void MoveCamera()
{
var horizontalVector = pivot.transform.forward * movementInput.x;
var verticalVector = pivot.transform.up * movementInput.y;
pivot.transform.position += horizontalVector + verticalVector;
}
To zoom my camera I use orthographicSize
.
To move my camera I move pivot on Y and Z axis of object. That way my camera moves the way I want.
To rotate my camera I rotate pivot on Y axis and here’s a thing - camera doesn’t rotate the way I want. I want my camera to rotate when position of Z axis of pivot is 0, because that way it rotates as I want it to, around what you actually see.
What can I do to achieve this?