Script failing to play animation
Hello,
I'm trying to animate an object. It should, when a button on my controller is pressed, play said animation. When I press the button for DecreaseChannel it sends Animate! to the console, however, the animation does not run and I get Animator.GotoState: State could not be found. I have also attached a screenshot of the animated object's properties.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
public class WaveD : MonoBehaviour
{
PlayerControls controls;
private Animator animate;
void Start()
{
animate = GetComponent<Animator>();
}
void Awake()
{
controls = new PlayerControls();
controls.Gameplay.DecreaseChannel.performed += ctx => playAnim();
}
// Update is called once per frame
void Update()
{
}
void playAnim()
{
Debug.Log("Animate!");
animate.Play("Assets/Scripts/Waves.anim", 0);
}
void OnEnable()
{
controls.Gameplay.Enable();
}
void OnDisable()
{
controls.Gameplay.Disable();
}
}
screenshot-2022-05-04-172726.png
(66.8 kB)
Comment
Your answer

Follow this Question
Related Questions
How to add lighting to specific parts of sprite? 0 Answers
Stuck Selected animation state Button with fake click 0 Answers
my animation glitches when i add more keyframes 0 Answers
How to add bones to a mesh 0 Answers
Can Not Load Animation of Jump 0 Answers