[VRC Constraints] Processing order of the converted VRCConstraints may differ from the original
available in future release
logi_9
I'm using a trick for copying transforms in local space using Unity's constraints. (It is a part of VirtualLens2.)
The trick is not working with auto-conversion by the current beta.
Video: https://youtu.be/jfNLX47NW_8
Avatar: avtr_8b1b20d1-e94a-44ab-84c6-a8ef0fbd98c5
How the trick works
Its hierarchical structure is as follows:
+ WorldOrigin: Root object.
It is fixed to world space by a constraint.
+ Controller: Input pose. It is near the head in the demo.
+ Joint0
+ Leaf0
+ Joint1
+ Leaf1
+ SourceOrigin: Origin of input space.
It will be fixed to world space by "Lock Source".
+ TargetOrigin: Origin of output space.
It will be fixed to world space by "Lock Target".
+ Object: will be moved by this system.
It works by toggling between two states for every frame.
For (2n+0)-th frames:
- Joint0: Copy transform of the SourceOrigin in world space by its Parent Constraint.
- Joint0/Leaf0: Copy transform of the Controller in world space by its Parent Constraint.
For (2n+1)-th frames:
- Joint0: Copy transform of the TargetOrigin in world space by its Position/Rotation Constraints.
- Joint0/Leaf0: Keep local transform from the previous frame by disabling its constraints.
- Object: Copy transform of Joint0/Leaf0 in world space.
We can use another Joint/Leaf pair (Joint1/Leaf1) for pipelining. Then, we can copy transform in local space with a single-frame delay.
Expected behavior
It works similarly to the live version (
w_2024.2.3p2-cd3e635c6e
).Actual Behavior
The pose of
Object
is unstable. It seems that the processing order of the constraints is different from expectation.Log In
This post was marked as
available in future release
Dexvoid
Merged in a post:
[VRC Constraints] Processing order might be wrong
logi_9
This avatar has an implementation of "Fixed to World" by referencing an out-of-scene prefab similar to Unity Constraints-based implementation.
The sphere should be fixed completely in world space if it is working as expected. However, it has vibrated with the movement of its original parent, the right hand.
Avatar: avtr_18923526-bc47-4541-8e50-4ab7ae4d6804
Video: https://youtu.be/dLKRvn-z8s0
Avatar Overview
The following figure describes an object hierarchy of the avatar:
+ (AvatarRoot)
+ ...
+ (RightHand)
+ CameraRoot
+ Droppable
+ Origin
+ TransformReference
+ Root
+ Local
+ Capture
+ Sphere
+ Transform
+ WorldFixed
+ Unstabilized
+ Result
Some GameObjects have VRC Constraint components as follows:
- WorldFixed: Parent and Scale: Empty Prefab (out of the scene)
- Unstabilized: Position and Rotation: TransformRefernce
- Result: Position and Rotation: Unstabilized
- Droppable: Parent: Result
- Capture: Parent: Origin
Also, this avatar has three animator states:
Init
(until enabling Enable
)- Disables CameraRootandLocal
- Enables constraints of Unstabilized
Neutral
(Drop==0
)- Enables CameraRootandLocal
- Enables constraints of Unstabilized
Drop
(Drop==1
)- Enables CameraRootandLocal
- Disables constraints of Unstabilized
When
Drop
is enabled, Unstabilized
will be fixed in world space. (it is a widely used technique for Unity Constraints on VRChat.)Expected and Actual Behaviors
In the
Drop
state, constraints can be processed without referencing any transforms from the previous frame in the following order.- WorldFixed
- Result
- Droppable
- Capture
However, it appears that a different order is used, which causes the object to move one frame later, causing the Sphere to vibrate.
AFAIK, Unity Constraints correctly parses dependencies as long as circular references are not present, and should have been able to handle such cases without referencing the transforms of previous frames.
logi_9
This issue may be related to https://feedback.vrchat.com/open-beta/p/vrc-constraints-processing-order-of-the-converted-vrcconstraints-may-differ-from , but since I don't know the implementation details and cannot determine the cause, I'm submitting it as a separate ticket tentatively.
If the root cause is the same, please merge them.
StormRel
tracked