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 2d animation rig: How to change bone rotation with script while animating?

Discussion in '2D' started by Upp000, Feb 28, 2023.

  1. Upp000

    Upp000

    Joined:
    Mar 4, 2021
    Posts:
    96
    How to change bone rotation with script while animating?
    I know in normal unity animation, I can just do it in late update,
    but in 2d animation rig,
    it only changes the bone, the render result is still the same as the animation.
     
  2. MarekUnity

    MarekUnity

    Unity Technologies

    Joined:
    Jan 6, 2017
    Posts:
    203
    Hi @Upp000,

    We are making a change in the latest Animation 10.0 package (targeting Unity 2023.1) to address this issue.
    To work around it, you could set the add the DefaultExecutionOrder(-2) attribute to your script so that it executes before the deformation happens:
    Code (CSharp):
    1.     [DefaultExecutionOrder(-2)]
    2.     public class YourScript : MonoBehaviour
    3.     {
    4.         void LateUpdate()
    5.         {
    6.             // Here is code modifying the bone transforms
    7.         }
    8.     }
     
    Upp000 likes this.