- Home /
AnimationEvent not reliably triggerd on iPhone
when i try to dynamically add an AnimationEvent to the end of a AnimationClip, everything works fine in the editor. on the iphone (3gs + 4) everything went fine as long as the rest of the scene was empty, but the more objects i added/more rendering needed, the event started to drop/not been called more and more and with the full scene, it nearly never got called.
i did a dirty workaround now, but still wondering if AnimationEvents under stress will not get called reliably. or did i just make a stupid mistake, as i'm new to unity?
thanks a lot for any hints!
here's the (simplified) code not working properly:
AnimationClip actionClip;
void Start() { AnimationClip actionClip = animation.GetClip ("action");
AnimationEvent AniEndEvent = new AnimationEvent ();
AniEndEvent.functionName = "OnActionEnded";
AniEndEvent.time = actionClip.length;
runClip.AddEvent (AniEndEvent);
animation.Play(actionClip.name);
}
private void OnActionEnded() { Debug.Log("action ended"); }
Answer by Paulius-Liekis · Dec 02, 2010 at 06:17 PM
There used to be a bug which caused animation not to be sampled at last frame. It might be that the same problem causes the event not to be executed. I fixed the sampling bug, so it might be that the event bug is fixed too. I fixed a bunch of other event bugs too...
You can try setting wrapMode to ClampForever and see if that helps you.
i finally tried with clampforever for the update and it did the trick. not heavily tested, but worked on all our intern devices. thanks for the hint!
Your answer
![](https://koobas.hobune.stream/wayback/20220613085236im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
The name 'Joystick' does not denote a valid type ('not found') 2 Answers
Using the "Fade"-Class crashes unity-iphone build... 1 Answer
Unity Invoke method delay factor vary device to device 1 Answer
Animation not playing when returning to a previous loaded scene 2 Answers
How to change transform.position.x after a state is changed? 1 Answer