Hi, in my game I want the player to be able to look around the scene using their finger to drag the screen around. I have the code below and it’s working except for if the player touches a random place on the screen instead of dragging it the camera rotates to a random position really fast. I only want the camera to move when the screen is being dragged not just tapped.
using UnityEngine;
using System.Collections;
public class CameraMovement : MonoBehaviour {
public float speed = 0.1F;
void Update() {
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Moved) {
Vector2 touchDeltaPosition = Input.GetTouch(0).deltaPosition;
transform.Translate(-touchDeltaPosition.x * speed, -touchDeltaPosition.y * speed, 0);
}
}
}