Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Unity Animation Event - No function selected

Writer Matthew Barrera

I googled and tried a lot and right now just going crazy, cause its just a simple thing that takes to much time to be solved. So in the web there are two types of posts:

  1. Console gives error "No function selected" and the solution is that some ppl added by accident an animation event and didnt set it up. <-This not what Im looking for
  2. I added an animation event to my clip, but clicking on the drop-down "Function" says "No Function Selected"and does not let me select anything. <- This is what Im looking for. This kind of posts never got an answer.

This is how it looks like:enter image description here

Hierarchy:

Object 1
 Object 1.1 <- Has a script from where I start animations
 Object 1.2 <- Has the animator. Rotate and scale object 1.2

More Information:Yes, I selected at first my Object 1.2, selected then the right clip in the Animation-Window and added an animation event.

0

1 Answer

This kind of posts never got an answer

Please allow me to doubt that.


Simply make sure that your setup fulfills the following conditions:

AnimationEvent requires

  • the Component from which you want to use a method is attached to the same GameObject as the Animator component
  • the method you want to call has accessibility and return type public void
  • the method you want to call has none or maximum one parameter
  • the supported types for the parameter are int, float, string, UnityEngine.Object, AnimationEvent

Since your script is on another GameObject you could redirect the call e.g. like

public Redirector : MonoBehaviour
{ // Either drag in via Inspector [SerializeField] private ScriptOnOtherObject _scriptOnOtherObject; // or get at runtime if you are always sure about the hierachy private void Awake() { _scriptOnOtherObject = transform.parent.GetComponent<ScriptOnOtherObject>(); } // and now call this from the AnimationEvent public void DoIt() { _scriptOnOtherObject.TheMethodToCall(); }
}
4

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.