In the Multi Parent Constraint the offsets stored for “Maintain Position” do not respect runtime scaling (it would be extremely helpful if it did btw) so I am writing my own simple parent constraint to get around that.
In this constraint I’m mimicking lossy scale(which again, would be great to have that in jobs) by getting the scale of the hierarchy above the constrained transform and I ran into some weirdness. After some debugging I found that ReadOnlyTransformHandle.GetLocalScale() is not behaving the same way that it does in UnityEngine.Transform.localScale on the transform that has an Animator attached to it. In jobs that Transform gives you a lossy scale, whereas in UnityEngine.Transform it gives you local scale.
Here’s a simple repo in which I’m logging the local scale of a hierarchy to the console at runtime with both regular monobehavior(top) animation rigging jobs(bottom)
Is this a bug or expected behavior?
Here is a package with these assets:
Thanks
This really feels like a bug to me but for anyone with this problem of offsets not scaling at runtime a simpler way around it than writing your own constraint is to create your own offset setup that respects runtime scale like this:
- Turn off Maintain Offset
- Create a GameObject with a RigTransform component and parent it to the Source transform
- Move/Rotate it to the Constrained transform
- Create an OverrideTransform component going from new GameObject to Constrained transform
I have since learned from looking at one of the built-in constraints that you can pass data (such as lossyScale) via the job binder’s Update loop using AnimationJobCacheBuilder(). This gets me exactly what I needed.
Hey! Would you mind taking a look at my reddit post? If I understand correctly, your problem seems to be pretty similar to the issue I’m currently facing. Maybe you can help me with that one:
https://www.reddit.com/r/Unity2D/comments/1ccmn30/rig_not_working_properly_when_changing_localscale/