- Home /
Animation event not firing when out of view
We have a rather odd issue at the moment with Animation Events.
A character contains an animation which, at a particular point, calls a function on the object called Fire(). This instantiates a projectile, which is propelled for a certain distance before detonating.
A UI button controls the firing animation being triggered. When the desired frame is reached, the projectile appears, flies across the screen and detonates perfectly well. However, on running the game on device we noticed that the projectile wasn't being created while the character was off screen (it is a strategy game, hence this need). In every case, the projectile appeared and assumed its trajectory the moment that character was back on screen (even after waiting 20-30 seconds).
So I tried the following experiment back in the editor: if the game camera is moved so that the character is no longer in its frustum, will the same thing happen? Reassuringly, the projectile was still instantiated fine. HOWEVER, if the other window (scene view) was ALSO not looking at the character, we got the ignoring of the animation events. I had not realised the editor's view could actually affect the way the game behaves; is this truly the case?
To summarise: are animation events affected by being rendered (eg. is the animation component disabled at some low level), and is there a relatively painless way to get animation events to trigger regardless of camera visibility?
Thanks!
Answer by Novodantis · Feb 12, 2013 at 10:38 AM
Don't you just love the way a solution to a problem only presents itself when you've just asked for help with it?
I didn't notice the animation component's "Culling Type" field, which by default is "Based on Renderers". Changing to "Always Animate" fixes the issue.
Thanks for reading!
Your answer
Follow this Question
Related Questions
Near plane adjustment in Scene View 3 Answers
Align scene view camera to HUD camera? 0 Answers
using assets in scene window and hierarchy 1 Answer
All objects missing from scene view except the canvas 2 Answers