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. Have a look at our Games Focus blog post series which will show what Unity is doing for all game developers – now, next year, and in the future.
    Dismiss Notice

Question How do I Rotate an Object (with C#) while Animation is Playing?

Discussion in 'Animation' started by Seth01Master, Apr 24, 2022.

  1. Seth01Master


    Feb 26, 2022
    Me and my friend have been working on a little project and we encountered a small problem with our player.
    We want to script a system that shoots a blast of fire out of the characters hand when you left click. But the problem is that we want to rotate the arm to point in front instead of downwards (like our walking animation).
    But we still want to keep it smooth, so we tried to rotate the arm while the animation was playing.
    But nothing happened. The fire particle and everything else still worked perfectly- but the arm did not rotate. We tried to uncheck "Apply Root Motion" as that's what other people said would solve the problem, but the only thing that did was make the player move slower. Can I have some help?

    The game is third-person by the way, so we would like to be able to keep the transition as smooth as possible and still have the current animation play while the arm is forward.

  2. Rodrigo_Ronin


    Feb 4, 2016
    Hi @Seth01Master

    You can't move the bones of your character while he is being controlled by an animation unless you use Animation Rigging.

    Instead of explaining to you how it works, I'll leave a link here to a Brackeys's video where he explains that better than I would.

    Link of the video:
  3. Flylake


    Feb 26, 2014
    Hi Seth

    Afaik bones can only be manipulated from the code/script and in the LateUpdate method, because anything done before that is overridden by the animator

    Your problem is not a new one, and I suggest checking out Final-IK asset on the store, its abit expensive but it´s well worth its cost.

    the "AimIK"-component can be setup so that set of bones will rotate accordingly until a desired vector points towards your target (like the local forward vector of your weapon for instance)

    that is how i approached the issue
  4. Seth01Master


    Feb 26, 2022
    Sorry I haven't replied sooner, but I solved the problem with animation rigging! Thanks!