Hi
I am trying to play an animation when user touches a 3D model. My problem is that animation is not playing at all if I uncheck “Loop Time” in my animation state. And If I check that it doesn’t play at all.
here is my script where i am trying to play this animation
void Update()
{
if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began)
{
Ray ray = Camera.main.ScreenPointToRay( Input.GetTouch(0).position );
RaycastHit hit;
if ( Physics.Raycast(ray, out hit) && modelObjects.Contains(hit.collider.gameObject))
{
Debug.Log("Object touched");
//hit.collider.gameObject.transform.Rotate(transform.up, 30.0f);
hit.collider.gameObject.animation.Play("TapAnimation");
}
}
}
here is unity editor screen shot i have Animator and Animation both components attached to my object. My animation name is TapAnimation
http://s23.postimg.org/89xar8gyz/Unity_Editor.png
http://s23.postimg.org/9q8t9djvv/Tap_Animation_State.png
Its just a simple rotate 360 deg animation which I want to do on touch.