Why does my Animator not switching states?
Hi, I have a problem and hope somebody can help me.
I want to start the Open animation when my FirstPersonController enters a collider (trigger is activated) and play the Close animation when my FirstPersonController exits the collider. But the animation isn't played ingame and in the Animator there is no transition to the next state. Actually I want to play the Open-Animation backward by setting the speed to -1 in the inspector, but because I already had problems with that (the animation didn't play at all) I am happy when first of all my animation plays in the game.
What is a bit strange: When I play and manually check or uncheck the condition the animation plays ingame. But elsewise not. Although the Debug.log says me, that the condition is properly set.
Here are my settings and the script:
using System.Collections;
using UnityEngine;
public class BridgeOpen: MonoBehaviour
{
public AudioSource audioZug;
private Animator anim;
//public bool isOpen;
void Start()
{
anim = GetComponent<Animator>();
audioZug = GetComponent<AudioSource>();
}
void OnTriggerEnter(Collider other)
{
if (other.tag == "Player")
{
anim.SetBool("isOpen", true);
audioZug.Play();
Debug.Log("Get Bool: " + anim.GetBool("isOpen"));
}
}
void OnTriggerExit(Collider other)
{
Debug.Log("OnTriggerExit");
if (other.tag == "Player")
{
anim.SetBool("isOpen", false);
audioZug.Play();
Debug.Log("Get Bool: " + anim.GetBool("isOpen"));
}
}
}
Your answer
Follow this Question
Related Questions
Transitioning between walking running idle animations with floats 0 Answers
Animator problems with transition 1 Answer
Why is the animation clip preview different than ingame? 0 Answers
How to stop already started transition in the animator and run next animation immediatley 0 Answers
Animation Running Game 0 Answers