Converting Mouse to Touch

Hi there I really could use some help with this:

I made a script which allows me to target a object and rotate around it using the A and D keys, Script found below:

#pragma strict

public var speed : float = 135.0; // Degrees per second

public var object : Transform;

function Update() {

transform.RotateAround(object.position, Vector3.up, -Input.GetAxis(“Horizontal”) * speed * Time.deltaTime);

}

I found this part really easy, however I have no idea how to translate this into a touch input. So for instance I have a see through Touch pad located at the bottom left of my screen, (it is a rectangle that is lightly see through) how would I when I drag my finger left and right up and down on the touch pad be able to move the Camera around the object in that Direction?

So it would create an effect of moving the camera around the object whilst it is still looking at my object?

Any Ideas would be Appreciated!

Start using the Touch object and the Touch input to handle multiple finger as an array.

Then use Touch.position to handle the location.

As far as I know Unity doesn’t allow you to instantiate Touch event objects, so you have to write a layer on top that takes touch inputs and mouse inputs and then read that from your game. There’s code out there for this: google “unity simulate touch with mouse”.

public var speed : float = 135.0; // Degrees per second

public var object : Transform;

function Update() {
if (Input.touchCount > 0)
{
     transform.RotateAround(object.position, Vector3.up, -Input.GetTouch(0).deltaPosition.x * speed * Time.deltaTime);
}

}