So my camera is following a way point system where the camera moves between the two positions and stays focused on the same point. I want the camera once it stops moving to be able to move when the player right clicks, here is my code:
void Update()
{
camStuff.Reset();
rotStuff.Reset();
rotStuff.mousePos = Input.mousePosition;
camStuff.cameraPos = mainCam.transform.position;
if(Input.mousePosition != rotStuff.mouseOldPos && moving == false && Input.GetMouseButtonDown(1))
{
RotateCamera();
}
if(camStuff.cameraPos != camStuff.oldCameraPos)
{
moving = true;
} else
{
moving = false;
}
if (Input.GetMouseButtonDown(0))
{
MoveCamera();
}
}
/*
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
// Translate along world cordinates. (Done this way so we can angle the camera freely.)
transform.position -= new Vector3(touchDeltaPosition.x* PanSpeed, 0, touchDeltaPosition.y* PanSpeed);
*/
void RotateCamera()
{
mainCam.transform.rotation = new Vector3(rotStuff.mouseOldPos.x * mouseSensitivity, 0, rotStuff.mouseOldPos.y * mouseSensitivity);
}
struct RotationStuff
{
public Vector3 mouseOldPos;
public Vector3 mousePos;
public void Reset()
{
mouseOldPos = mousePos;
mousePos = Vector3.zero;
}
}
Thank you.