I’m trying to add a function to fire on a certain frame, but the function I need will not show up in the edit animation event window. How do I fix this?
animation event calls public methods of other components attached to gameObject playing the animation
so basically make component (monobehaviour class) AnimationEventListener and make public method like
public void EventHandlerMethod()
{
// the code you need
}
attach it to the gameObject in scene and it should appear in the dropdown menu of AnimationEvent keyframe
Check out this answer: Why don't animation events allow you to call functions that take a bool parameter? - Unity Answers
If you have a boolean parameter, it doesn’t show
Old question but I worked this out, if you select an animation clip in the Project explorer and try and edit an event’s properties it wont show a list of available functions.
However If you select an object in your scene graph with an Animator component then bring the Animation window and select your clip in the dropdown it will show a list of functions you can call. It makes sense because Unity won’t know which functions it can call just by editing the animation clip asset, it needs the context of the game object that’s playing it.
Thanks. This is one of those things that if you don't do often, even if you know it, you may forget. I'm really glad you posted your answer!
– WhippersnapperFor anybody else who lands here, the animator can only call methods with a single parameter. If you have several parameters, it won’t appear on the list. You have to pass a parameter of type AnimationEvent
. Here are more details: One parameter limit on animation event functions temporary? - Unity Answers
but how can I fix the problem if I want to call a function that is in another game object that the animation clip is on, the function is public and I tried locking the inspector on the animation clip, then selecting the game object that has the function I want to call but still no result ! @Floranceflore
Old question, but another issue that might cause this is attaching the script to a child of the object holding the animator, the script must be attached to the parent object for the function to show.
I used a public function and put the script into the game object with the Animator component.
© 2022 - 2025 — McMap. All rights reserved.
Ok, but the animation event window only shows functions from the parent gameobject. How do I make it show the functions of the child gameobjects?
– Creditablei'm not sure you can do that, but for sure you can call them from the parent component http://docs.unity3d.com/Documentation/ScriptReference/Component.GetComponentInChildren.html
– Dasi