Does anyone know of a tutorial that will help me make a grab and drag style camera? I want to be able to click and drag on the surface of the game world to move the camera around on the x-y axis (not up and down). I have written this script for the camera and it works, but it’s really half assed since i don’t really know how to make exactly what i want.
P.S. The reason I am changing Y to Z is because Input.mousePosition returns Y as up and down and for some stupid reason transform.position uses Z as up and down. Why can’t everything just use Z?
var HasClicked = false;
var ClickedPosition = Vector3(0,0,0);
function Start ()
{
}
function Update ()
{
if (Input.GetMouseButton(0))
{
if (HasClicked == false)
{
ClickedPosition = Input.mousePosition;
HasClicked = true;
}
var NewVec = ClickedPosition - Input.mousePosition;
NewVec.z = NewVec.y;
NewVec.y = 20;
transform.position = NewVec;
}
else
{
HasClicked = false;
}
}
Thanks