So I have a Gramophone, and my goal is on interact a coroutine plays my handle crank animation then play the looping animation of record turning, and on interaction again the animation stops, I made a script for it but got a few errors, any suggestions
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class gramoscript : Interactable
{
public Animator anim;
public bool turnhandle = false;
public bool playmusic = false;
public bool MusicPlay = false;
void start()
{
anim = GetComponent<Animator>();
}
public override void OnFocus()
{
}
public override void OnInteract()
{
if (MusicPlay == false)
{
StartCoroutine((MusicOn));
}
else if (MusicPlay == true)
{
StartCoroutine((MusicOff));
}
}
public override void OnLoseFocus()
{
}
IEnumerator MusicOn()
{
SetBool("MusicPlay", true);
anim.SetBool("turnhandle", turnhandle);
yield return new WaitForSeconds(5);
anim.SetBool("playmusic", playmusic);
}
IEnumerator MusicOff()
{
yield return new WaitForSeconds(5);
animator.SetBool("playmusic", false);
SetBool("MusicPlay", false);
}
}