VRC Constraint Sources cannot be edited in any way at runtime with U#
tracked
Vincil
The documentation for VRC constrains implies you can edit a constraint's sources at runtime. The only runtime limitations given in the documentation is that the target transform cannot be changed, that "changing a transform reference at runtime can cause performance issues."
In my scene I have a rode-shaped VRC pickup with a child transform representing the tip.
Separate from it I have a sphere with a VRCPositionConstraint and the below script attached. The
targetSource
serialized field points to the pickup's tip transform.```c#
public class TestConstraintRuntime : UdonSharpBehaviour
{
[SerializeField] Transform targetSource;
private void Start()
{
VRCPositionConstraint constraint = GetComponent<VRCPositionConstraint>();
constraint.Sources.Add(new VRCConstraintSource(targetSource, 1f));
Debug.Log($"Sources count: {constraint.Sources.Count}");
constraint.IsActive = true;
constraint.ApplyConfigurationChanges();
}
}```
When the constraint's source is set to the tip in inspector, the constraint performs as expected. But when it is not set in the inspect and assignment is left to the script at runtime, nothing happens.
I also attempted to change at runtime the weight an inspector set constraint source using the method specified in the documentation (pulling out a source; setting the weight field; and then returning the source), but that also failed to have any impact.
For sanity I tried to perform the same logic with a Unity constraint and that worked without issue.
Either this is a bug or the documentation needs to clarify that these changes cannot happen at runtime.
Log In
StormRel
updated the status to
tracked
Solàzu
I'll put in my 2 cents here, since i've been stuck on VRC Constraints myself too.
The only thing that works is "Set Item". But i only tested that one with an empty Source.
Add/RemoveAt/Remove/Insert/SetLength Don't work, FixedSize is false so it shouldn't be an issue.
Normal unity constraints don't have the issue in question.