Unity Animation Event - No function selected
10,371
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 theAnimator
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();
}
}
Comments
-
Perazim almost 2 years
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:
- 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
- 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.
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.2More Information: Yes, I selected at first my Object 1.2, selected then the right clip in the Animation-Window and added an animation event.