Programmatically adding a constraint during play mode causes "Target Transform" to not be respected
available in future release
Dor․
Constraints latch the "target transform" on
Awake
during play mode, even if the constraint is not yet active, this makes it impossible to add a constraint and configure it on the same frame programmatically without first disabling the game object that the constraint is added to (preventing Awake
from firing) and re-enabling the object after configuring it.Log In
This post was marked as
available in future release
This post was marked as
tracked
Dexvoid
updated the status to
needs more information
Only the getter of
TargetTransform
is exposed to Udon. Additionally, AddComponent()
is not exposed to Udon, so adding a constraint programatically seems it would be impossible at this time unless you're referring to instantiating a prefab that has a constraint in it.Can you please provide a code sample demonstrating what you're trying to do? Is this for world development in Udon, or is it in reference to an editor tool written in C#?
Dor․
Dexvoid It's for an editor tool, adding constraints non-destructively, doing so when a "play mode build" is created requires you to workaround the
Awake
target transform latch (if there's a target transform being set) by turning off the object the constraint is added to, adding the constraint and configuring it, then turning it back on, my expectation is that the latching wouldn't happen until the active bool is set (directly or via the activate/zero methods), and/or update the latched target transform under similar conditions or when the ApplyConfigurationChanges
method is called.Clearer documentation regarding the transform being latched should probably be added too, this tripped me up for a few hours before I figured it out.
Dexvoid
Dor․ Sorry but I'm still a little confused, wouldn't an editor tool like this only need to run in edit mode? Entering play mode causes changes to the scene to be lost once you exit play mode.
If by "play mode build" you're referring to making builds of avatars from play mode like how it worked in older SDKs, please note that this approach is now deprecated and no longer officially supported. Users are expected to make avatar builds via the SDK control panel in edit mode instead.
You can implement the
IVRCSDKPreprocessAvatarCallback
interface if you want to inject your own logic into the build process of an avatar. This interface receives the avatar that is being prepared for upload, not the original instance of it in the scene, which supports making non-destructive changes.Dor․
Dexvoid Certain avatar tools such as vrcfury and ndmf execute a build when entering play mode so that non-destructive elements could be tested (usually with other tools such as gesture manager or av3emulator), the "play mode build" I described is entirely meant for this use case - testing before upload.
My code works perfectly fine when uploading, it is simply that testing it with the play mode build is impossible without explicitly working around the (undocumented) transform latch.
StormRel
updated the status to
tracked