Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to add momentum to sword swing

Discussion in '2D' started by TalliDown, Sep 5, 2016.

  1. TalliDown

    TalliDown

    Joined:
    Sep 5, 2016
    Posts:
    2
    Just starting out with Unity..

    I have an animated sprite that will swing his sword when triggered. I want to add momentum to that swing. This means that the character should move forward with the swing somewhere halfway through the sword swing animation.

    I can add a force to coincide with the start of the swing, but this is not what I want: i need it to start halfway through.

    How can I accomplish this?

    Thx!
     
  2. JayJennings

    JayJennings

    Joined:
    Jun 24, 2013
    Posts:
    184
    Did you know you can tell your animations to kick out an event at any point you specify? Then you can "react" to that event. See this page:

    http://docs.unity3d.com/Manual/animeditor-AnimationEvents.html

    I only played with that once and ran into a weird bug so stopped using it, but that was many moons ago and the bug is probably fixed and I was doing something non-standard anyway, so give it a shot.

    Jay
     
    PeaceLaced and theANMATOR2b like this.
  3. TalliDown

    TalliDown

    Joined:
    Sep 5, 2016
    Posts:
    2
    This works perfect.

    Thank you!
     
    PeaceLaced and JayJennings like this.