- Home /
Animation occurs but doesn't show in-game
I have a GameObject (plank) with an Animation component that slides it away if the user walks up to a trigger collider and presses the E key - here's the code for the GameObject holding the trigger collider:
void Update () {
if(detected == true && Input.GetKeyDown(KeyCode.E) && doorOpened == false)
{
plank.animation.Play("LoosePlankAnimation");
doorOpened = true;
}
}
My issue is, in-game the animation runs but the plank stays completely still. I know the animation is running since I put a Debug.Log(plank.animation.IsPlaying()) statement in the Update function and it shows the animation is running when it should.
Oddly enough, once the animation is finished I can walk straight through the plank as if it has slided away in the way I want - but in no way does the animation itself show in-game.
Any ideas what might be the cause of this problem?
Does the plank have a rigidbody? Or could some part of the code be keeping it at its place?
The plank has the following components: Transform, $$anonymous$$esh Filter, $$anonymous$$esh Renderer, and a $$anonymous$$esh Collider. It also has a parent GameObject with only a Transform and an Animation component (holding the animation in question). Nothing seems out of the ordinary, and I have many similar objects with fully working animations.
As far as I know, no code I've written is holding it at its place - and it would only be effecting the $$anonymous$$esh Renderer anyway, since the collider seems to animate fine.