Question by
NewBeeLiu · Nov 29, 2015 at 08:14 PM ·
c#triggeranimationstouch controls
touch to activate animation
Hey guys,
I have a touch screen rotation script that works on rotating a object √
Now I want to keep track of the number of times I have turned it so that on the 3rd turn I can trigger a boolean to start an animation...
Here is the touch screen script below:
using UnityEngine;
using System.Collections;
public class rotateTest : MonoBehaviour {
public float speed;
public float xDeg,yDeg,lerpSpeed,friction ;
Quaternion fromRotation, toRotation;
// to keep track of initial Position ?:
public Vector3 initialPos;
//Number of orations..?
public int myNumberRotate;
void OnMouseDown()
{
//Pseudo Code:
//set initialPos;
//set myNumberRotate= 0;
}
void OnMouseUp()
{
//Pseudo Code:
// how to keep track of rotations around the Y Axis > 3...?
}
//TOUCH CODE BELOW WORKS FINE:
voidUpdate ()
{
if(Input.GetTouch(0).phase== TouchPhase.Moved)
RotateTransform(Input.GetTouch(0).deltaPosition.x, Input.GetTouch(0).deltaPosition.y);
elseRotateTransform(0f, 0f);
}
voidRotateTransform( floatxNum, floatyNum) {
xDeg -= xNum*speed*friction;
yDeg -= 0;
//yDeg -= yNum*speed*friction;
fromRotation = transform.rotation;
toRotation = Quaternion.Euler(yDeg,xDeg,0);
transform.rotation = Quaternion.Lerp(fromRotation,toRotation,1 );
}
}
Comment