4
\$\begingroup\$

In my Unity project, I had an issue recently where a tool which autogenerated animation controller layers caused issues with existing layers because it was generating layers with Write Defaults set to OFF, but the existing layers were full of states where it was set to ON.

On talking with others, I gather that mixing these two settings in the same controller causes chaos.

But the thing is, if that were truly the case, the UI would reflect that. It would just be a single checkbox on the entire controller, and I wouldn't be able to set it differently on every single node. Yet I can, so there must be a use case for mixing them.

Unity defaults this checkbox to ON, suggesting that they recommend that.

VRChat, on the other hand, recommend setting it to OFF.

So I don't know who is right on this but it creates an annoying situation where if I want to follow VRChat's recommendations I have to manually uncheck a checkbox on every single animator node, which isn't great UX.

So what I'm wondering is, exactly what does this checkbox do that makes a mix of the two settings break stuff, while setting everything to OFF or everything to ON apparently works fine together. Does it exist solely to torment new developers who don't expect that the editor has extreme quirks?

\$\endgroup\$

2 Answers 2

3
\$\begingroup\$

This is one of those questions you can answer with a search.

For me, the third result is the official documentation, stating:

Write Defaults: Whether or not the AnimatorStates writes back the default values for properties that are not animated by its Motion.

And the second result is this thread including a quotation from a Unity developer about why they chose to default it to ON:

In 5.0 we have added a property on the State to "Write back default values". Meaning that if turned on, it will write back the default values of all animated properties ( on a Controller wide-basis) that are not animated in that State.

By default, its "on", so we don't change the behavior that we had before.

So if you want the non-animated properties of a State to keep the value it had previously, simply turn it off.

So it looks like the default ON was chosen for backward compatibility with versions before 5.0, so as to not break pre-5.0 assets/projects that relied on this behaviour, not because they recommend it be left ON in every project. (If it were meant to always be left on, they would not have added the option to turn it off!)

If compatibility with VR Chat is important to your project today, then follow VR Chat's current recommendations, not a backward compatibility concession that was made for an ancient version of the engine from half a decade ago.

\$\endgroup\$
4
  • \$\begingroup\$ So this is a paper cut issue in Unity because they didn't distinguish between new projects (which should default to OFF) and migrated projects (which should default to ON)? \$\endgroup\$
    – Hakanai
    Sep 25, 2021 at 3:17
  • \$\begingroup\$ As Philipp points out in the other answer, both settings have their uses, which is why it's an option you can toggle. The thrust of this answer is that you should feel no pressure to use the default ON if you find that OFF better serves your needs. \$\endgroup\$
    – DMGregory
    Sep 25, 2021 at 10:08
  • \$\begingroup\$ Well, so far ON seems to have caused me less trouble overall. It was only using with this one tool where I have ever even had to think about this one annoying checkbox. Also, I think I had found that description in the changelogs too, but it was talking about "properties", and animators usually talked about "parameters", so I wasn't entirely sure what it was resetting, It also wasn't really in the main docs, and the UI doesn't even have the help icon to get to the docs. :( \$\endgroup\$
    – Hakanai
    Sep 26, 2021 at 2:25
  • 4
    \$\begingroup\$ Down voted for condescending suggestion of a search. They were clearly asking for a deeper explanation then Unity's single sentence useless documentation. \$\endgroup\$
    – HcgRandon
    Jan 6, 2022 at 3:33
3
\$\begingroup\$

As the documentation says, this setting decides what happens with those values which are not animated by this state, but are animated by another state in the same layer of this animation controller. When you switch it on, those values are reset back to the default upon entering this state. When you switch it to off, they retain whatever values they had after exiting the previous state.

Regarding the conflicting recommendations regarding "always on" and "always off": It is perfectly possible to mix both behaviors in the same animation controller, and there certainly are use-cases for it. But for consistency reasons, it can be useful to stick to either one or the other as a default setting. It makes it easier for you to form a mental model regarding how animation state transitions work in your game.

\$\endgroup\$
1
  • 1
    \$\begingroup\$ "Upon entering the state" is interesting info that could possibly be added to docs if true. So I guess if I have properties A and B, both 0, and an animation changes B, and I have an animator which changes A to 1, then another animator changes only B to 1, if the B animator has Write Defaults set then it will set A to 0 when it starts, which interferes with the A animator in a sense. \$\endgroup\$
    – Hakanai
    Sep 26, 2021 at 2:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .