question on calling an animation from a script.

hey,

I would like to play an animation when a crit hit happens on my game im working on. This is the script that I have so far.

tapToFishButton.GetComponent ().Play = fishingCritHitAnim;

here is a look at the whole statement i have.

if(Random.value <= GameController.control.shrimpFishingCritChance)
                    {
                        tapToFishButton.GetComponent<Animation> ().Play = fishingCritHitAnim;
                        Debug.Log ("Crit Hit Fishing!");
                        GameController.control.shrimp += GameController.control.shrimpPerTap;
                    }

but i get an error saying
Assets/Assets/Scripts/TapToFish.cs(80,84): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer

So I understand i need to put something else on the left hand side of the script, but i am unsure what that would be. Any ideas? thanks!

Play is a method not a variable.

create a Bool in your Animator/Parameters. Apply that Bool on your Animation Transition state. Call the Bool via script like this. Make sure this script is on the same Transform as your Animator for this code to work.

using UnityEngine;
using System.Collections;

public class AIAnimation : MonoBehaviour
{
    private Animator anim;

    void Awake()
    {
        anim = this.GetComponent<Animator> ();
    }

    void FixedUpdate ()
    {
        Animotion ();
    }

    private void Animotion ()
    {
     anim.SetBool ("Sring", Bool);
    }
}