Increase animation speed according to the swipe speed in unity for Android

Posted by rohit on Game Development See other posts from Game Development or by rohit
Published on 2014-04-03T09:29:10Z Indexed on 2014/06/03 3:44 UTC
Read the original article Hit count: 356

Filed under:
|

I have the animation done through Maya and brought the FBX file to unity. Here is my code to calculate the speed of the swipe:

Vector2 speedMeasuredInScreenWidthsPerSecond =(Input.touches[0].deltaPosition / Screen.width) *     Input.touches[0].deltaTime;

Now I wanted to take speedMeasuredInScreenWidthsPerSecond and use it to increase the animation speed accordingly like this:

animation["gmeChaAnimMiddle"].speed=Mathf.Round(speedMeasuredInScreenWidthsPerSecond);

However, this results in an error that I need to convert Vector2 to float.

So how do I overcome it?

© Game Development or respective owner

Related posts about unity

Related posts about unityscript