Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question StateMachine OnStateExit Call Function

Discussion in 'Animation' started by Deyia, Jun 21, 2020.

  1. Deyia

    Deyia

    Joined:
    Dec 14, 2019
    Posts:
    5
    Hi! i'm calling a function on my animation at the end to clean a few things and i want to call that function with OnStateExit to make sure it's always called. The problem is that i cant find a way to call the function.

    Any help would be greatly appreciated, thanks in advance.

    Resume question: i want to call function from stateMachine same way i do from animationEvent

    Full Question Explained:

    i'm calling this method with Event on animation.
    Picture Below:
    Sin título.jpg

    this works great, but if i transition to another animation before that event is triggered, the function is never called. So i'm trying to use a statemachine and call this event on "OnStateExit" wich is always called at state exit.

    I just cant find the code to trigger that same function "AbilityFinish"

    upload_2020-6-21_2-17-19.png
     
  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,554
    animator.SendMessage("AbilityFinish");
     
  3. Deyia

    Deyia

    Joined:
    Dec 14, 2019
    Posts:
    5
    That is exactly what i was looking for, thanks a lot!

    Solved, please any mod close it.
     
  4. Gametyme

    Gametyme

    Joined:
    May 7, 2014
    Posts:
    618
    Is there another way besides send message?
     
    Lorrak likes this.