I have an animation that rotates a door 90deg and when I try to play the game, it doesn’t show the door rotating. However, if I look in the inspector, it says the door has rotated.
I’ve remade my animations & animator controllers several times, thinking that might be the problem, but to no avail.
Any suggestions?
explain the setup, the hierarchy and what is triggering the door. Any code attached to the door?
I have an animator and box collider attached to the door (as well as the script below). The script works for other doors/drawers, but not this one. Debug.Log returns “animator’s busted”, so I know the RayCast collision is happening. The animator is a three-state animator with empty → open, open → close, close → open.
Also, as of this morning, it only sometimes registers the change in the inspector.
public class Drawer : Control
{
Animator drawerAnim;
Collider drawerColl;
private void Start()
{
drawerColl = gameObject.GetComponent<Collider>();
drawerAnim = gameObject.GetComponent<Animator>();
}
private void OnMouseDown()
{
if (CheckCollision(drawerColl))
{
drawerAnim.SetBool("open", !drawerAnim.GetBool("open"));
Debug.Log("animator's busted");
}
if (!CheckCollision(drawerColl))
{
Debug.Log("collider's busted");
}
}
}
Could you check to see if line 17 is firing with debug.log?
My second guess was this - but I can see this is not the case.
Hmm - collision - could the collision possibly be happening at the wrong time - maybe? Or maybe overlapping the trigger what collides with it to trigger the animation?
I’m a non-coding artist, so the code to me looks good
besides it says drawer instead of door, but I understand why.
1 Like
Debug.Log(drawerAnim.GetBool(“open”)) returns true, so idk why the animation isn’t going. 
Sorry I think I need to clarify. Does it return true before it is supposed to return true? Wouldn’t this cause the animation to fail because it is already true?
So I think I get what you’re saying, and I did this, and it returns false the first time, true the second time, and so on.
private void OnMouseDown()
{
Debug.Log(drawerAnim.GetBool("open"));
if (CheckCollision(drawerColl))
{
drawerAnim.SetBool("open", !drawerAnim.GetBool("open"));
}
}
1 Like
I just used a new desk model and the animations/animator are working perfectly so far.
1 Like
Maybe someone competent in code (not me) can chime in with a suggestion.