I have begun work on the camera movement for the editor of our game.
So far I have the panning working relatively well, but am having trouble with the camera rotation.
The issue is with the mouse position, I can only get a movement reaction by moving the mouse up or down, and nothing by going form side to side, which leads me to believe that I have left something out, but cannot see anything wrong with it.
What I am trying to achieve is being able to use the middle mouse button to pan around and the right mouse button to rotate the camera on the Y and Z axis.
using UnityEngine;
using System.Collections;
public class CameraControl : MonoBehaviour
{
public float mouseSensitivity = 0.01f;
private Vector3 lastPosition;
void Update()
{
if(Input.GetMouseButtonDown(2) || Input.GetMouseButtonDown(1))
{
lastPosition = Input.mousePosition;
}
if(Input.GetMouseButton(2))
{
Vector3 delta = Input.mousePosition - lastPosition;
transform.Translate(delta.x * mouseSensitivity, delta.y * mouseSensitivity, 0);
lastPosition = Input.mousePosition;
}
if(Input.GetMouseButton(1))
{
Vector3 delta = Input.mousePosition - lastPosition;
transform.Rotate(0, delta.y * 1.0f, delta.z * 1.0f);
lastPosition = Input.mousePosition;
}
}
}