Can't play attack animation

I get these errors when I press the attack input:

public class PlayerAttackingState : PlayerBaseState
{
    private Attack attack;
    
    public PlayerAttackingState(PlayerStateMachine stateMachine, int attackId) : base(stateMachine)
    {
        attack = stateMachine.Attacks[attackId];
    }

    public override void Enter()
    {
        
    }

    public override void Tick(float deltaTime)
    {
        stateMachine.Animator.CrossFadeInFixedTime(attack.AnimationName, 0.1f);
    }

    public override void Exit()
    {
        
    }
}

I’m not sure this is the cause of the error, but the line you have in Tick needs to be in Enter, or it will try to move to the state every frame and never really progress (Tick runs every frame, you only want to call CrossFadeInFixedTime once).
The error message itself looks like the AnimationName does not match any of the states in your animator. (case matters)

1 Like

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.

Privacy & Terms