I have an Animator on this gameObject. The Animator hits one state when some parameters are true, it can transition to this state from any state. The parameters are fine because i can see in the animator that the state is getting hit when i want it to. The blue progress bar is showing, but the animation doesn't play on the screen in the game, it just shows the state before it. I have tried changing exit time, apply root motion, update mode, static batching. Nothing works Help pls internet gods
As requested here are some images, first this is my animator and the transition that is set up: (I have also tried this with the same transition but from flies buzzing directly and the same behaviour happens)
Also here is what the animation state looks like and the preview of it, showing that it works in scene (just not in game)
And here's how it behaves in game, as you can see the blue bar is progressing (and this is going into the state at the correct time, after dealing 2 damage to the fly, isDead gets set to true). However the only animation that plays is the fly buzzing one.
Here's my code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class FlyCombatAndFollow : MonoBehaviour
{
[Space]
[Header("References:")]
public Animator animator;
public GameObject fly;
[Space]
[Header("Character attributes:")]
public int maxHealth = 2;
int currentHealth;
// Start is called before the first frame update
void Start()
{
currentHealth = maxHealth;
}
public void TakeDamage(int damage)
{
currentHealth -= damage;
//Play hurt animation
animator.SetTrigger("IsHit");
animator.SetInteger("Hit", damage);
if (currentHealth <= 0)
{
StartCoroutine(Die());
}
}
public IEnumerator Die()
{
Debug.Log("Fly died");
//play death animation
animator.SetBool("IsDead", true);
yield return new WaitForSeconds(1.0f);
//Disable fly
Destroy(fly);
}
}