Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice

Showcase Precise Animation Control and Smooth Transitions with Animation Events and Blending in Unity

Discussion in 'Animation' started by brucesierra, Jan 19, 2023.

  1. brucesierra


    Jan 19, 2023
    Hey everyone,

    I've been working on a new animation system for my Unity project and I wanted to share it with the community.

    The system is based on animation events, which allows for more precise control over when certain animations or events occur. For example, I can have an animation of a character shooting a gun, and I can set an animation event to occur at the exact frame where the gun is fired. This allows for more accurate and believable animations.

    I've also implemented a system for blending animations, which allows for smooth transitions between different animations. This can be used for things like footstep blending, which ensures that the character's footsteps match the animation that is currently playing.

    Overall, I'm really happy with how the system has turned out and I hope that others in the community find it useful as well. Let me know if you have any questions or if there's anything I can do to improve the system.

    Here's some sample code for the animation event:

    void Shoot()
    // Code to play gunshot sound and spawn bullet prefab
    And here's some sample code for the animation blending:

    void Update()
    // Code to determine which animation should be playing
    animator.CrossFade("Walk", 0.2f);
    Please feel free to give me your thoughts, and feedback or if you have any questions. I will be happy to help you out! or contact me here: Animation Services