Problems with colliders and animation.

I’m making a 2d platformer game and I have platforms that I want to fade in an out over time. When I did this through scripting to disable the BoxCollider2D component it worked just fine. When I try to use the Animator to do this, it will allow me to start with the collider off and then enable it but then it won’t ever disable it. Even when I try to make a script event in the animator to disable it through code or manually disable it in the inspector it still stays enabled. The only property the animations are effecting is the alpha channel of the color. Is this a bug or is it intentional. I would think it is a bug because no matter what I do with an animator on it I can’t turn off the BoxCollider2D.

Double check that you’ve setup the animation correctly, and that no other scripts are keeping the BoxCollider2D enabled. I’ve attached a small lookup project for you to check, it contains a platform, which has a BoxCollider2D enabled/disabled through the animation.

3261669–251535–AnimTest.zip (47.1 KB)

Thanks, it is working for me now. I’m still not sure what happened. I have 3 animations for my platform. an idle for the entry which disables the BoxCollider2D and sprite renderer. then it triggers the appear animation and never goes back to the idle animation and the appear and vanish animations were the only thing that was controlling the BoxCollider2D being enabled or not. I removed the BoxCollider2D property from the idle animation and it still didn’t work so I removed the idle animation completely and it worked. I put the idle animation back in and again it didn’t work even though it had no property of the BoxCollider2D. So, I restarted unity and it seems to have magically fixed itself and is working fine.