I have a basic camera setup which is angled like so:
x: 30
y: 0
z: 0
Projection: Orthographic
And i attached a C# component to it and made it so the camera moves with a right click and drag movement.
The problem is its not moving at the same amount as the mouse. I had to set a value for scroll speed to 1000 and even then its still too slow.
I want the camera to move with the mouse in a more raw amount, then i wish to add some lerp effect to it so it feels a bit more slick.
I don't know why the movement is so slow, i come from a 2D background and am learning 3D so i suspect my lack of understanding of 3D positions might be the issue.
This is my current code:
using UnityEngine;
using System.Collections;
public class cameraMove : MonoBehaviour {
// VARIABLES
public float panSpeed = 1000.0f;
private Vector3 mouseOrigin;
private bool isPanning;
void Start ()
{
Vector3 pos = GameObject.Find("Sun").transform.position;
Camera.main.transform.LookAt (pos);
}
// Update is called once per frame
void Update ()
{
if (Input.GetMouseButtonDown (1))
{
//right click was pressed
mouseOrigin = Input.mousePosition;
isPanning = true;
}
// cancel on button release
if (!Input.GetMouseButton (1))
{
isPanning = false;
}
//move camera on X & Y
if (isPanning)
{
Vector3 pos = Camera.main.ScreenToViewportPoint (mouseOrigin-Input.mousePosition);
// update x and y but not z
Vector3 move = new Vector3 (pos.x * panSpeed, pos.y * panSpeed, 0);
Camera.main.transform.Translate (move, Space.World);
mouseOrigin = Input.mousePosition;
}
}
}
