Write Default Bugs in Unity
Unity's animator has tons of undocumented bugs involving Write Defaults (WD), blendtrees, layers and masks, many of which are still being discovered to this day. Some depend on the WD setting; others happen with either setting. These are the bugs we are currently aware of.
The examples below were tested in Unity 2022.3.22f1 on Windows, in both Edit Mode and Play Mode. The PhysBone examples use SDK 3.10.6-beta.4. Other Unity and SDK versions may behave differently.
An earlier layer appears higher in the layer list. A later layer appears further down the list and normally has higher priority. WD Off does not always mean "leave this property alone": a state can keep writing a property's previous value even if its animation does not contain that property.
WD Off Layers Prevent WD On Resets
A WD Off state in one layer can prevent WD On states in another layer from resetting properties. After a WD On state animates a property, entering another WD On state which omits it can leave the property at its previous value. This can happen even if the WD Off layer never animates that property.
Keeping each layer entirely WD On or entirely WD Off does not prevent this bug, and moving the layers around does not guarantee that the reset will work. In VRChat, all playable layer controllers share one animator, so keeping them in separate controllers does not prevent interference either.
Avoid mixing WD where possible, while keeping direct blendtrees and additive layers WD On. If you need a reset, you can explicitly animate the default value, but this can change blending and what later WD Off states remember. A defaults layer at the top can also fix some cases. Do not continuously reset properties which need to keep their previous values with WD Off, and note that a defaults layer does not fix blending against earlier layers.
Animations can still explicitly change the property in this case. If even explicit curves cannot change it, see WD Off None Motions Can Freeze Animated Properties.
WD Off Restores Values From Before a WD On Reset
Mixing WD settings within one layer can make a property return to an older value after a reset. For example:
- A WD Off state animates the property to 20.
- A WD On state omits it, making it return to its default of 3.
- A WD Off state also omits it, and the property jumps back to 20.
If the middle state explicitly animates the property to 3 instead, the following WD Off state keeps 3. An explicit reset can therefore change what later states remember.
Keeping all states within a layer on the same WD setting avoids this particular problem.
WD Off Direct Blendtrees Can Accumulate Values Every Frame
In an unnormalized direct blendtree with WD Off, a child which omits a property can still add its previous value to the blend. Values may grow or shrink every frame, causing them to fly off into oblivion. For example, after a property is set to 10, one child animating it to 10 and another omitting it, both at weight 1, can produce 20, 30, 40, 50 on successive frames.
An earlier layer animating the property every frame can stop the growth, but the values from the two layers may still be added together incorrectly. Putting the direct blendtree inside a 1D or 2D blendtree does not prevent the problem.
Keep states containing direct blendtrees WD On, including states where the direct tree is nested inside another tree. A tree with only one child, or with every property animated in every child, may appear to work with WD Off; adding more animations can break it. Normalizing the tree can stop the growth in some cases, but changes how its weights combine.
WD On direct blendtrees can still suffer from failed resets and incorrect blending against earlier layers, including when they share a layer with ordinary states.
WD Off Additive Layers Can Add Unanimated Values
A WD Off state in an Additive layer can add unwanted values for properties which its active blendtree children omit. For example, with a default of 3 and an earlier layer setting 5, a 1D tree fully weighting a child which omits the property can produce 8 instead of leaving it at 5. This does not require a direct blendtree.
Keep all states within Additive layers WD On.
Normalized WD Off Blendtrees Can Drift with Constant Inputs
Ordinary 1D and 2D blendtrees, as well as normalized direct blendtrees, can also reuse a property's previous value when their active children animate different sets of properties. If an earlier layer is not supplying the property every frame, the result can keep changing even when the clips and blend parameters are constant.
For example, starting at 3, a 1D tree blending halfway between a clip setting the property to 10 and one omitting it can produce 6.5, 8.25, 9.125, 9.5625 on successive frames.
To avoid this, animate each shared property in every relevant child. Continuously animating it in an earlier layer can also stop the feedback, if the property does not need to keep its previous value. Adding default curves can change how the tree blends with earlier layers.
Retained Values Overwritten by Other Layers
WD Off does not remember a separate value for each layer. Suppose an earlier WD Off layer animates a property to 20, then enters a clip which animates other properties. A later layer overrides it to 10, then stops animating it. The earlier layer may keep 10 instead of restoring its original 20.
This can happen even if each layer uses only WD On or only WD Off. Changing the later layer to WD Off does not fix it.
Keep the earlier layer explicitly animating the value which should return after the override, or avoid sharing properties which a layer needs to remember. Reordering layers or adding default curves is not a general fix.
WD Off Controllers Can Block Other Controllers' Animations
A later WD Off controller in a mixer (usually FX in VRChat) can claim ownership of unmasked transforms. It can prevent earlier controllers from animating transforms which it never explicitly animates, even if those earlier controllers use WD On. Only the later controller needs to use WD Off for this interference to occur.
The interference is not limited to transforms. A WD Off controller animating one float on a component can prevent another controller from animating a different float on the same component. A controller playing a real empty clip can also interfere; see WD Off Empty Clips Can Block Resets and Other Controllers.
Possible workarounds include:
- Use WD On for the affected controllers. The other WD On issues on this page still apply.
- Combine Gesture and FX. This removes the interference between those controllers, but the resulting controller can still have the other layer problems described here.
- Add masks to FX to exclude the transforms needed by earlier controllers. This is not always practical because masks can break other properties.
Muscle Clips Can Override Muscles They Do Not Animate
A clip animating a humanoid muscle can override other muscles which it does not animate, both across layers within one controller and across separate controllers in a mixer. For example, a later clip animating only the left arm can prevent an earlier layer from animating the right arm, if the later layer's mask allows the right arm.
This happens with WD On as well as WD Off. The blocked muscle does not need to appear anywhere in the later controller, and the later layer does not need to animate it first. Giving each muscle to only one controller is therefore not enough to prevent interference.
Use a humanoid body-part mask to exclude the parts which should come from earlier layers. These masks exclude whole body parts, not individual muscles: excluding the right arm also excludes its other muscles. When mixing controllers, the mask needs to apply to the controller's mixer input as well. In VRChat, the SDK copies a custom controller's base-layer mask to its playable-layer mask.
If the later layer should temporarily override the earlier one, use Animator Layer Control or Playable Layer Control to weight it to 0 when the animation is complete, as is done with Action. Moving to a real clip containing only non-muscle bindings can also release the muscles. A WD Off "none" motion can still lock them; see WD Off None Motions Can Freeze Animated Properties.
Avatar Masks Can Block Material Swaps and PhysBone Properties
An Avatar Mask containing explicit transform paths can break some animations on that layer or controller mixer input. Both WD On and WD Off are affected:
- Material swaps on slots greater than 0 can be blocked, even when every listed transform is enabled.
- Material swaps on slot 0 can also be blocked. Enabling the renderer's path or an ancestor's path can allow the swap, so this does not follow exactly the same rules as masking transform animations.
- PhysBone enum properties, such as Integration Type, and object references, such as Root Transform, can be blocked. Float and bool properties including Pull, Gravity, Radius and Is Animated can still be animated, even when every transform path is disabled.
A mask with no transform paths did not cause these failures. If you only need humanoid masking, use a mask with no transform paths. Enabling every path in an existing transform-path mask does not fix material slots greater than 0 or these PhysBone enum and reference properties. Keep affected animations out of layers or mixer inputs with these masks.
In Unity alone, a mask on the controller's base layer does not automatically mask its other layers. In VRChat, the SDK copies a custom controller's base-layer mask to its playable-layer mask, which can affect the whole controller.
WD Off None Motions Can Freeze Animated Properties
A WD Off state with a "none" (null) motion, or a null blendtree child, can freeze properties which its layer previously animated. Earlier layers can then be prevented from changing those properties even with explicit animation curves. This also happens when both layers use WD Off; mixed WD settings are not required.
Replace "none" motions and null blendtree children with real animation clips. A clip containing at least one property, which does not have to be a valid binding, avoids this lock in the tested cases. Weighting the offending layer to 0 can also release the lock, although this cannot be done to the controller's base layer.
Replacing null motions does not fix every problem caused by missing curves or separate controllers. Real empty clips behave differently.
WD Off Empty Clips Can Block Resets and Other Controllers
A real animation clip with no animated properties behaves differently from a "none" motion. Within one controller, it can avoid the null-motion lock, allowing earlier layers to change a property with explicit curves. The WD Off state can still prevent WD On resets.
For example, after a later layer animates a property and enters an empty clip, an earlier layer can change it from 10 to 20. If the earlier layer then relies on WD On to reset it, it can stay at 20.
Across separate controllers in a mixer, an empty clip can still cause the controller interference described above, blocking explicit animation curves in an earlier controller. These are the same reset and controller-interference problems; using an empty clip does not avoid them. Use the workarounds in those sections. Adding a dummy binding does not fix either problem.
WD On Transitions Can Ignore Earlier Layers
On an override layer, a WD On state transition can blend from the object's default (resting) value instead of the value supplied by an earlier layer. This happens when one state animates the property and the other state omits it. It can happen with ordinary animation clips; blendtrees and animated parameters are not required.
For example, suppose the default is 3 and an earlier layer continuously sets 5. A later WD On layer is in a state which omits the property, so the visible value is 5. It then transitions to a state setting 10. Halfway through, the result is 6.5, blending from 3 to 10, instead of 7.5, blending from 5 to 10.
The reverse transition has the same problem: it blends from 10 toward 3, then returns to the earlier layer's 5 when the transition finishes. This can cause a jump at the start or end of the transition.
If the intended values are known, explicitly animate them in both states. Animating a fixed default is different from following a value supplied by an earlier layer, so this is not a general fix for sharing animated properties. Adding a base defaults layer does not fix the transition either.
For ordinary clip states, WD Off can blend against an earlier layer which supplies the property every frame. The other WD Off problems on this page still apply, and any required resets need explicit curves. Keep direct blendtrees and Additive layers WD On.
Blendtrees can also use the default instead of the earlier layer's value.
Partial Blendtree Weights Can Ignore Earlier Layers
Partial blending inside a tree on an override layer can use the default value instead of the value from an earlier layer. This does not require an Additive layer. It uses defaults in a similar way to WD On state transitions.
For example, with WD On and a default of 0, an earlier layer sets 5. A later direct blendtree has one child setting 10 at weight 0.1 and another child omitting the property at weight 0.9. The result is 1 instead of 5.5: the missing contribution comes from the default of 0, ignoring the earlier layer's 5. If the animated child's weight drops to 0, the earlier layer's 5 can suddenly show through again.
An unnormalized direct blendtree can also fill missing weight from the default with WD Off. This can happen with one child or multiple children, even if every child animates the property. With a default of 3, an earlier layer setting 5, and two children each setting 10 at weight 0.05, the result is 3.7 instead of 5.5.
Adding another child does not fix an unfilled weight deficit unless it supplies the intended contribution. Adding a base defaults layer does not fix the blending either.
To avoid the problem:
- Avoid sharing properties between layers which involve open-ended blending.
- Animate shared properties in every child, using the values which should be blended together, and ensure the total contribution is fully weighted. Adding curves alone does not fix an unnormalized direct tree's weight deficit.
- For a shared property in a direct blendtree, keep its animated contribution fully weighted or zero.
- With ordinary normalized blendtrees, WD Off can blend against an earlier layer which supplies the property every frame. The other WD Off problems on this page still apply. Keep direct blendtrees and Additive layers WD On; changing an unnormalized direct tree to WD Off does not fix its weight deficit.
Replacing a direct blendtree with 1D or 2D blendtrees can change how the weights combine and how fast the animations play, so it is not a general fix.
Animated Parameters Can Delay WD On Resets Until a Transition Ends
With WD On, an animated float parameter in the controller can affect how a transition resets properties, even if that parameter is unrelated to the blendtree. This can happen when transitioning from a state animating a property to a tree whose currently weighted children omit it. The property can be absent from every clip in the destination tree.
Some properties can keep the source value throughout the transition, then return to an earlier layer's value or their default when it finishes. For example, with a default of 3, a source value of 20, and no earlier layer animating the property, Light intensity and a blendshape stayed at 20 until the transition ended. Without the animated parameter, they blended from 20 to 3. Transform position still blended normally in the same test.
This can happen with 1D, 2D and direct blendtrees, including normalized direct blendtrees. Transitions where both states explicitly animate the property can still blend normally.
Explicitly animate the intended reset value in the relevant children to avoid relying on WD during the transition. This can change blending with earlier layers. Avoid animated parameters where possible, although this is often unavoidable. Switching to WD Off does not replace an authored reset and can introduce the blendtree problems described above.