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.