Hello,
I am searching for a script. When you swipe to the right, it plays an animation from a character and when you swipe to the left also.
I have android pro in unity.
Who can help me?
Hello,
I am searching for a script. When you swipe to the right, it plays an animation from a character and when you swipe to the left also.
I have android pro in unity.
Who can help me?
Google can help ![]()
http://forum.unity3d.com/threads/48601-Swipe-help-please?p=323387&viewfull=1#post323387
This might help you…
Vector2 TouchPos;
if (Input.GetTouch(TouchCntr).phase == TouchPhase.Began)
{
TouchPos = Input.GetTouch(TouchCntr).position;
return;
}
if (Input.GetTouch(TouchCntr).phase == TouchPhase.Ended)
{
if (Input.GetTouch(TouchCntr).position.y > TouchPos.y + 50)
SwipeY_UP = true;
if (Input.GetTouch(TouchCntr).position.y < TouchPos.y - 50)
SwipeY_DOWN = true;
if (Input.GetTouch(TouchCntr).position.x > TouchPos.x + 50)
SwipeX = true;
if (Input.GetTouch(TouchCntr).position.x < TouchPos.x - 50)
SwipeX = true;
}
But how do i use it? Like where do I put the script in and how is it going to play an animation?
Something like this:
if (Input.GetTouch(TouchCntr).position.x > TouchPos.x + 50)
SwipeX = true;
if (SwipeX = true : then animation.Play(“walk”);
I’m not that good in scripting, so what do you have to put in the SwipeX = true : then???
And where do I have to put the script in? Maybe in a new object which is not visable (game object → create empty)?
Thanks for your help!
I doupt your code will work
You dint declare TouchCntr