I followed a tutorial I found (a couple actually) and came up with a simple way to control a door animator which has been hooked up to control keyframe animations embedded into the model.
This works fine when I manually change the Toggle Parameters Open/Close in the Animator window, but when attempting to do the same programatically (by triggering ToggleTrigger, with or without arguments) nothing changes.
I have attached the script below the image of my Animator graph.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BulkheadDoorControllerScript : MonoBehaviour
{
public Animator animator;
//public variable
public bool isOpen;
//set the animator based on input value currentPosition
public void ToggleTrigger(bool currentPosition)
{
if (currentPosition)
{
animator.SetTrigger("Open");
}
else
{
animator.SetTrigger("Close");
}
}
//override method sets the animator, then toggles the public bool
public void ToggleTrigger()
{
isOpen = !isOpen;
ToggleTrigger(isOpen);
}
}
I drag the Animator component onto the animator variable slot in the Inspector, then when triggering the change, seemingly nothing happens, in the Game, Scene or Animator windows.
Can anyone see what exactly it is that I am doing wrong?