KeyboardOrbit with DualTouchControls

Hi, I have problem with moving camera with KeyboardOrbit script using DualTouchControls prefab. Touchpad works great with FirstPersonCharacter (disabled when orbit camera is active), but I can’t move orbit camera with touchpad even if touchpad is set to the same axis… :frowning:

Touch Pad Settins
53000-capture1.jpg

Keyboard Orbit Settings (orbit camera)
53001-capture2.jpg

When KeyboardOrbit is set to Horizontal and Vertical or Mouse X and Y, it works well on pc keyboard/mouse, but on phone don’t. I also created ZoomAxis but it also don’t work with this script (in this case only Fire1 Fire2 axis works).

In orginal KeyboardOrbit script I added/changed:

public string horizontalAxisName = "Horizontal";
public string verticalAxisName = "Vertical";
public string zoomAxisName = "ZoomAxis";

x -= Input.GetAxis(horizontalAxisName) * xSpeed * 0.02f;
y += Input.GetAxis(verticalAxisName) * ySpeed * 0.02f;

distance -= Input.GetAxis(zoomAxisName) *zoomSpeed* 0.02f;
distance += Input.GetAxis(zoomAxisName) *zoomSpeed* 0.02f;

ZoomAxis settings:

Name ZoomAxis
Negative Button -
PositiveButton +
Gravity 1000
Dead 0.001
Sensitivity 1000
Snap off
Invert off
Type Key or MouseButton
Axis X axis
Joy Num Get Motion from all Joystics

I found the solution. I had to add/change some lines to the KeyboardOrbit script that read touch imput.

using UnityEngine;
using System.Collections;

public class CameraMoveTouchscreen : MonoBehaviour {
	
	public Transform target;
	public float distance= 1.5f;
	public float xSpeed= 175.0f;
	public float ySpeed= 75.0f;
	public float pinchSpeed = 0.5f;
	
    private float lastDist = 0;
	private float curDist = 0;
	
	public int yMinLimit= 10; 
	public int yMaxLimit= 80;
		
	public float minDistance= 0.5f; 	
	public float maxDistance= 1.5f;
		
	private float x= 0.0f;
	private float y= 0.0f;
	
	private Touch touch;
	
	
	void  Start () {
		Vector3 angles= transform.eulerAngles;
		x = angles.y;
		y = angles.x;

		// Make the rigid body not change rotation
		if (GetComponent<Rigidbody>())
			GetComponent<Rigidbody>().freezeRotation = true;	
	}
	

	void  LateUpdate (){
		if (target && GetComponent<Camera>()) {

			if (Input.touchCount == 1 && Input.GetTouch(0).phase == TouchPhase.Moved) {
				
				touch = Input.GetTouch(0);
				x += touch.deltaPosition.x * xSpeed * 0.02f;
				y -= touch.deltaPosition.y * ySpeed * 0.02f;
				y = ClampAngle(y, yMinLimit, yMaxLimit);
			}

			if (Input.touchCount == 2 && (Input.GetTouch(0).phase == TouchPhase.Moved || Input.GetTouch(1).phase == TouchPhase.Moved)) {

				Touch touchZero = Input.GetTouch(0);
				Touch touchOne = Input.GetTouch(1);

				Vector2 touchZeroPrevPos = touchZero.position - touchZero.deltaPosition;
				Vector2 touchOnePrevPos = touchOne.position - touchOne.deltaPosition;

				float prevTouchDeltaMag = (touchZeroPrevPos - touchOnePrevPos).magnitude;
				float touchDeltaMag = (touchZero.position - touchOne.position).magnitude;

				float deltaMagnitudeDiff = prevTouchDeltaMag - touchDeltaMag;

				distance += deltaMagnitudeDiff * pinchSpeed * 0.02f;
				distance = ClampAngle(distance, minDistance, maxDistance);

		}
			Quaternion rotation= Quaternion.Euler(y, x, 0.0f);	
			Vector3 vTemp = new Vector3(0.0f, 0.0f, -distance);
			Vector3 position = rotation * vTemp + target.position;
			
			transform.rotation = rotation;
			transform.position = position;	
		}
	}
	

	static float ClampAngle (float angle, float min, float max) {
		if (angle < -360)
			angle += 360;
		if (angle > 360)
			angle -= 360;
		return Mathf.Clamp (angle, min, max);	
	}
}