Search Unity

Cant seem to get Mecanim Events to work.

Discussion in 'Animation' started by Purpleshine84, Apr 5, 2014.

  1. Purpleshine84

    Purpleshine84

    Joined:
    Apr 8, 2013
    Posts:
    185
    I cant find any descent tutorial or documentation on how to script events from an animationclip. I am talking about Mecanim here (not about the Legacy system). Please, if someone could give me an example that would be great.
     
  2. jtdev

    jtdev

    Joined:
    Apr 13, 2014
    Posts:
    9
    In the animation clip import inspector, go to the Events (bottom one) and add an Event for the time you (use the Play and Scrub controls there in the preview window below it). Make sure you are adding it right, the little buttons there to add an Event are not intuitive. And fill in the function name field, you'll need it later for the code.

    Then, in the component on an object running that clip, add a function named the same as the name you gave it when you created the Event above.

    It uses SendMessage to call your function delegate.