Here is the thing!
I want to Touch a particular object in the screen and then change its animation.
I came up to this so far:
using UnityEngine;
using System.Collections;
public class Cop : MonoBehaviour {
Animator anim;
void Start ()
{
anim = GetComponent<Animator> ();
}
void FixedUpdate ()
{
if (Input.touchCount > 0 && Input.GetTouch (0).phase == TouchPhase.Began )
{
if(anim.GetBool("IsSelected")==false){
anim.SetBool ("IsSelected",true);
}
else{
anim.SetBool ("IsSelected",false);
}
}
}
}
This changes the animation but when i press somewhere on the screen,but i want to change it only when the touch is on the particular object.I think something has to be done with raycast but i dont know what .
Thanks in Advance!