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. Dismiss Notice

Question AnimationRigging: playing keyframes on top of a rotation

Discussion in 'Animation' started by The_Wb, Oct 13, 2022.

  1. The_Wb


    Jul 20, 2019
    Hi, everyone. I haven't used Animation Rigging package before and I'd like a tip on how to properly set an animation up

    I have an object, which is a part of the rig, and it can be rotated using the game logic, separate from the animation. What I'd like to have is being able to stack an animation on top of it, no matter the object's rotation

    I've tried using the Override Transform with space set to Pivot and it's doing what I'd like, but in a reverse order: applying the animation values, then applying the Source object's rotation on top of it. I'd like to know if this can be done the other way around, so applying the Source object's rotation and then applying the animation's keyframe changes on top

    1. I have an animation keyframe with these rotation Euler angles values - x = -50, y = 0, z = -30
    So the object I'm animating looks up
    2. Let's say, I want the animation stack on top of y rotation at 180, so my expected Euler Angles would be x = -50, y = 180, z = -30
    3. By having a Space = Pivot Override Transform and setting the Source object's y rotation to 180, I instead get x = 50, y = 180, z = 30
    So instead of facing up at a different Y rotation, it's facing down because the Source object's rotation has been applied second to the keyframe's

    I'd love to know if there's an easy workaround or different Constraint type that I can use to fix the issue. Ideally, would love to avoid having complex heirarchies or having to manipulate another object's world position to have the animation "look" at it

    Edit: I've found that there's a dedicated forum for Animation Rigging, please move the question there if possible, cheers
    Last edited: Oct 14, 2022
  2. kruskal21


    May 17, 2022
    Hi. I would suggest adding a "Rig Transform" component to the bones you are altering yourself. This is a component that comes with the animation rigging package, and tells the rig builder to take the object's transform into account when solving constraints. Give it a try and see if it works.
  3. The_Wb


    Jul 20, 2019
    Thanks for the reply. It's a shame, but I couldn't find proper documentation on how to use it and I'm too busy and lazy atm to the look into the code

    I've come up with a different solution since asking the quesion. It turned out to be a simple order of operations problem (in this case, the multiplication of quaternions)
    So I've taken the code from the Animation Rigging repo on github for the Override Transform and made a custom Override Transform class, which changed the Pivot setting to factor in the Source Object's rotation and then apply the animation keyframes on top of it.

    This should be enough info for someone to tackle on the problem, but if anybody wants the files, I'll be happy to share