Currently, the "Link Variable To Animator" script from the most recent AC version (not the old one from the wiki) doesn't correctly link global variables to parameters due to the following lines:
if (variables == null)
{
ACDebug.LogWarning ("No Variables component found for Link Variable To Animator on " + gameObject, this);
return;
}
if (_animator == null)
{
ACDebug.LogWarning ("No Animator component found for Link Variable To Animator on " + gameObject, this);
return;
}
if (string.IsNullOrEmpty (sharedVariableName))
{
ACDebug.LogWarning ("No shared variable name set for Link Variable To Animator on " + gameObject, this);
return;
}
variables is always null when you are not using component variables, so the return stops the rest of the script from running.
It looks like you're new here. If you want to get involved, click one of these buttons!
Comments
This change allows "set variable" actions that change the global variable to affect the animator parameter, but overall the script still behaves very erratically (it won't synchronise the parameter on start/load, so starting the game or leaving the scene and coming back will leave the parameter unsynchronised).
And if you check "script sets initial value?" (not something I want to use, but I thought I'd test it anyway), for some reason the script will only change the global variable to match the animator parameter half the times I run the scene, and I'm not sure why this is inconsistent.
Thanks for the bug report - it's a silly issue, and a fix is already scheduled to be included in the next update.
To fix in the meantime, replace line 54 with:
Is it the variable value that's correct, or the parameter?
As in, exiting-entering Play mode multiple times only causes the two to become linked every other time?
The two should become synced only when accessed - i.e. checking/setting the variable with Actions. It should be noted that if you only want the link to go one-way (variable -> parameter), you can remove both the compoment and the variable's Link to property, and replace it with a much simpler script:
Thanks! That's exactly what I was looking for, a one-way link from variable to animator.
Yes, this. I'm not sure why this was happening. If the parameter was 2 and the variable was 3, the variable would only become 2 some of the times I entered Play mode. The rest of the times, it'd remain 3.
Would it be possible for you to PM me a repro package/project that I can test this behaviour with?