Animation Not Triggering from Script in Unity

Hi everyone,

I’m facing an issue with triggering an animation in Unity, and I’m hoping to get some insights from this community. I have an animation for a door that was exported from 3ds Max and I’m trying to trigger it in Unity using a C# script. However, the animation is not playing when I use the script, although it works fine when I trigger it manually in the Animator.

Here is the current script I’m using:

using UnityEngine;

public class DoorController : MonoBehaviour
{
private Animator animator;

private void Awake()
{
    animator = GetComponent<Animator>();
}

void Update()
{
    if (Input.GetKeyDown(KeyCode.Space))
    {
        animator.SetTrigger("Op");
    }
}

}
The Animator component is attached to the door object, and it has a trigger named “Op” in the Animator Controller. The animation should play when the Space key is pressed, but nothing happens in the game view.

Things I’ve checked and confirmed:

  • The Animator component is correctly assigned in the script.
  • The “Op” trigger is correctly named and set up in the Animator Controller.
  • The animation plays correctly when triggered manually in the Animator.

I exported the animation from 3ds Max and it’s supposed to show the door opening and then closing. It’s not set to loop.

Has anyone experienced a similar issue or can provide any suggestions on what might be going wrong or what I should check next?

Thanks in advance for your help!

Andres :confused: