Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question Constraint weight reset after changing playable graph

Discussion in 'Animation' started by PixelFireXY, Feb 19, 2024.

  1. PixelFireXY

    PixelFireXY

    Joined:
    Nov 2, 2011
    Posts:
    56
    Hello,

    I'm facing an issue where the weight of my constraints is reset every time the playable graph changes in my project.

    I need a way to override my multi-parent constraint behaviour to prevent the weight from changing when the playable graph is modified.

    I've tried a few solutions to fix this issue, but none have worked as intended so far.
    I considered using Playable.KeepChildrenConnected = true to prevent the disconnection and reconnection of playables from affecting the weight, but I decided against it due to performance concerns.
    I also tried rebinding and setting the weight after, but it didn't solve the problem.

    I'm seeking advice or suggestions on tackling this problem without compromising performance. I'm open to any ideas or suggestions the community might have.

    Attached are the two scripts I've created to override the constraint.

    Thank you in advance!
     

    Attached Files:

  2. Kybernetik

    Kybernetik

    Joined:
    Jan 3, 2013
    Posts:
    2,592
    The performance might not be as bad as you think. When I did mine, the difference in frame rate was under 10% with animations being the only thing happening so in a real game with other stuff going on the overall difference would be even smaller. The numbers may vary with a different model and different number of animations so I'd recommend comparing it yourself. The reason I don't like that approach is mainly just that it's inconvenient to need to initialise everything upfront when that isn't otherwise necessary.

    If you do manage to come up with another solution though, I'd love to hear it because this seems like a really stupid limitation for the system to have.
     
    PixelFireXY likes this.
  3. PixelFireXY

    PixelFireXY

    Joined:
    Nov 2, 2011
    Posts:
    56
    Sure thing.
    I'm stubborn, I'll figure out something sooner or later.