- Home /
Changing mouse input to touch input... How ?
This script works fine but I need switch to touch input. Hope someone can teach me how to do...
using UnityEngine;
using System.Collections;
public class RotateAround : MonoBehaviour {
public Transform target;
public float xSpeed = 125.0f;
public float ySpeed = 50f;
private Vector3 startDirection = Vector3.zero; //How far away to orbit
private float x = 0.0f;
private float y = 0.0f;
private float z = 0.0f;
private Quaternion startRotation;
private Quaternion rotation;
void LateUpdate()
{
// if (Input.touchCount == 1)
if (Input.GetMouseButtonDown(0))
{
startDirection = (transform.position - target.position);
startRotation = transform.rotation;
x = 0.0f;
y = 0.0f;
z = 0.0f;
}
// if (TouchPhase.Moved)
if (Input.GetMouseButton(0))
{
x += Input.GetAxis("Mouse X") * xSpeed * 0.02f;
y -= Input.GetAxis("Mouse Y") * ySpeed * 0.02f;
z = 0.0f;
Reorient();
}
}
void Reorient()
{
rotation = Quaternion.Euler(y, x, z);
transform.rotation = rotation * startRotation;
transform.position = rotation * startDirection + target.position;
}
}
Comment
Your answer
Follow this Question
Related Questions
Convert Mouse-Input to Touch-Input..How?? 1 Answer
Is it possible to test Touch event without IOS? 1 Answer
Convert Touch input to Mouse input C#? 1 Answer
Convert Mouse Input to Touch Input 0 Answers
Touch / mouse code. 1 Answer