# Animation is not starting even though collider is triggered?

progress is steady but it is a bumpy road. I have removed the animation script from my character and reworked it into the controller script. I have also added new animations. Doing this required replacing the character FBX I was using earlier.

Doing this has caused an unexpected problem: Remember that super-cool item box that I made, that the character can trigger when he jumps under it, causing it to play an animation where the lid pops off? Well, that's broken now. The box's idle animation still plays, but the GetItem animation does not. Before importing the new character, his animations and the box's animations were in the same animation controller. I separated them into their own controllers, and applied them each where they belong. I did not make any more changes ( you can see all its properties in the demos below). There are still no transitions or parameters for the ItemBox. Funny enough, I tested it and the ItemBox's trigger is being activated. What could be wrong?

Link to video of new character demo

How can I get the GetItem animation to play for my itemBox again?

whoops, here is the relevant script:

ItemBox.cs:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class ItemBox : MonoBehaviour
{
// Start is called before the first frame update

bool disabled = false;
Animator anim;

void Start()
{
anim = GetComponentInChildren<Animator>();
if (!disabled)
{
anim.Play("ItemBox_Idle");
}
}

// Update is called once per frame
void Update()
{

}

void OnTriggerEnter (Collider other)
{
if (!disabled && other.gameObject.tag == "Player")
{
print("itembox triggered");
anim.Play("ItemBox_GetItem");
disabled = true;
}
}
}


**This is the heirarchy for the ItemBox prefab. Notice that animation frames can only be seen from first child ("Parent") of that prefab, downward: **

UPDATE! GetItem animation is playing in the animation graph while I play the game, hitting the box from below, but the animation doesn't play in the game! The plot thickens! See (shorter) video:

shorter video

• It looks like you're asking two different questions here. Please ask one question at a time, and include in the body of your question itself the FULL details of how you set up your animation controller and transitions so that we can reproduce the problem you're seeing without needing to ask you follow-up questions. – DMGregory Jul 17 '19 at 1:39
• Done. My animation controller is in the video link and it only has two animations in it. I'll upload a picture too – hatinacat2000 Jul 17 '19 at 1:55
• Help! I just learned by running the animation graph at the same time I play that the animation I am not seeing IS PLAYING, but not showing up! What could this mean? Very strange! – hatinacat2000 Jul 17 '19 at 4:11

I fixed it.

With elbow grease and magic.

There were some complications that contributed to this problem:

• First, the prefab consist of an empty called "parent" and 4 children under that (so there are 5 objects inside the prefab). It is "parent" WITHIN the prefab that contains the animations. In the original working version, I had the trigger, script, and regular collider at the top level of the prefab and the animation controller attached to "parent". This was weird from the start but I still don't know why it suddenly STOPPED working just by re-importing the character.

• What worked was moving all 3 components (script, trigger, and plain-old box collider) to "parent" which already has the animator attached to it. After doing this, none of the animations could be seen playing live in the Animator panel anymore, but the idle animation still played. I got lucky on one of my jumps and activated "GetItemState" animation in the Game. This meant that on top of all the problems I knew I had, I also had to enlarge the trigger again to make activation reliable. So I shrunk the plain box-collider by 1/10, moved it up, and scaled the depth of the trigger so my character would be reliably read as passing through it.

• Checking "apply root motion" had effects when other components were at the top level, sometimes moving the prefab instance to the origin during preview, but had no effect at all after every component got moved to "parent".