Hi all,
Basiclly I have a touch rotate thing going on that I want to convert to mouseClick-drag rotate:
//Speed You drag Object at
var speed : float = 0.1;
//How quickly it slows down
var dragFactor= 0.9;
//a storage space for translating touch-drag amount, to convert to object rotation.
static var translationVelocity: Vector3;
static var newTranslationVelocity: Vector3;
//The Sphere collider that is what will rotate, taking the 3d model with it.
var cam: Camera;
function Update () {
//// new samplecode: if(Input.GetMouseButton(0)){
if (Input.touchCount ==1 ){
////How to convert this stuff to mouse-related input?
for (var i = 0; i < Input.touchCount; ++i) {
//Has finger moved on device?
if (Input.GetTouch(i).phase == TouchPhase.Moved) {
////new sample code: var mouseDeltaPosition: Input.mousePosition;
//Where is our finger? This is evaluated every frame
var touchDeltaPosition:Vector2 = Input.GetTouch(i).deltaPosition;
////new sample code newTransationVelocity=Vector3(mouseDeltaPosition.x*speed,mouseDeltaPosition.y*speed,0);
//Get our translation speed, it will equal touch movement x "speed"
translationVelocity=Vector3(touchDeltaPosition.x*speed,touchDeltaPosition.y*speed,0);
}
}
}
cam.transform.Translate(-translationVelocity.x, -translationVelocity.y, 0);
//Apply Drag Factor so the translation slows down
translationVelocity -= (translationVelocity * dragFactor) * Time.deltaTime;
}
any advice on how to cache and read the new input would be awesome, thanks.
AaronC