Play an Animation through a Script


I’m trying to get something to react to a metronome script I’ve been messing with. The Metronome script I have uses events and delegates to allow multiple objects to be connected to it. I created a script called a “Metronome Reciever.” The script appears below:

public class MetronomeReciever : MonoBehaviour {

	public Animation bopAnim = null;
	public Metronome metronome = null;

	void Start()
		metronome.OnTick += OnTick;
		metronome.OnNewMeasure += DoOnNewMeasure;

	public void OnTick(Metronome m)

	public void DoOnNewMeasure(Metronome m)
		Debug.Log("New Measure");

I’ve been trying to get an animation to play with the “OnTick” function is triggered but I’m having problems with the animator. Using "bopAnim.Play(“Bop”), for instance doesn’t react the way I was expecting, with the animation only playing once at runtime when it should be playing on every tick.

Am I setting up my animator wrong or is there a specific way to reach animation states in the animator?

use an animator

Use an animator controller