Nodes attached to the same script don't animate.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By 9BitStrider

I have multiple “gate” node that are attached to a single script when spawned into the game. The code is below:

using Godot;
using System;

public class gate : StaticBody2D
{
    //Required Nodes.
    private world gamewrld;
    private audioManager audio;

    //Local nodes.
    private AnimationPlayer anim;
    private Area2D plyrDetect;

    //Other variables.
    public bool open = false;
    public bool plyrCheck = false;
    public int playing = 0;
    public bool needClosed = false;
    private Godot.Collections.Array bodies = new Godot.Collections.Array {};

    public override void _Ready()
    {
        //Grab all required nodes.
        audio = (audioManager)GetNode("/root/audioManager");
        gamewrld = GetParent().GetParent() as world;
        anim = GetChild(1) as AnimationPlayer;
        plyrDetect = GetChild(3) as Area2D;

        if (Name.Contains("hGateFull") || Name.Contains("vGateFull")) {
            needClosed = true;
        }
    }

    public override void _Process(float delta)
    {
        //Check to see if any bodies are overlapping the gate.
        bodies = plyrDetect.GetOverlappingBodies();

        if (bodies.Count > 0 && !plyrCheck) {
            var plyr = bodies[0] as player;
            //Pause player movement and animations.
            plyr.ctrl = false;
            plyr.pauseResume(true);
            audio.playSound("gate");
            anim.Play("open");
            plyrCheck = true;
        }
    }

    public void onAnimDone(string which) {
        GD.Print("Animation is done.");
    }
}

Everything works EXCEPT the animation. (It sends out the signal that the animation is finished even though the sprite itself DOESN’T change). I’ve checked and rechecked but the darn thing just won’t animate when the player slaps into it. Any ideas?

Edit: Sorry, didn’t mean to double post.