0
\$\begingroup\$

I have created a 1D blend tree. It is being used for a 3rd Person Controller.

The blend tree consists of 3 animations:

  1. aim pistol down to the floor
  2. aim pistol at middle of the screen (straight forward)
  3. aim pistol up in the sky

enter image description here

To determine the blend value (which animation should be played), I inspect the current mouse position and convert it a value between 0 (aim low) and 1 (aim high). The middle position would be 0.5. Here is my code:

float f = Input.mousePosition.y / Screen.height;

Debug.Log("Blendval " + f.ToString());//
_animator.SetFloat("BlendVal", f);

enter image description here

I tried to insert these decimal values in the blend tree like this:

enter image description here

However, this doesn't work. Unity converts my "0.5" to 0. I don't see why.

I can instead use integers like this:

enter image description here

Why doesn't Unity allow me to use 0, 0.5 and 1? Why do I have to use "other" values like -1, 0 and 1?

Thank you!

Edit:

I don't understand what is going on. I have just typed 0.5 here instead of 0:

enter image description here

And then suddenly I could enter the values as desired, and even "Automate Threshold" would do what I expected:

enter image description here

But now it won't accept negative values anymore.

Strange.

\$\endgroup\$
  • \$\begingroup\$ Looks like Unity thinks the parameter is of type "Trigger". Is your BlendVal parameter type set to "Float" (Animator Window, Parameters tab)? \$\endgroup\$ – Filip Milovanović Nov 14 '20 at 11:28
  • \$\begingroup\$ @FilipMilovanović Thank you but I think it's Float. I have added a screenshot showing this. I have manually entered the value "0.5", and it worked. \$\endgroup\$ – tmighty Nov 14 '20 at 11:34
1
\$\begingroup\$

There is a bug in Unity:

If you type the decimal separator as ".", it works.

But not if you use ",".

You can use "," anywhere else in Unity, and it will automatically be converted to ".", but not in the Blend Tree.

I have filed a bug report.

I will remove this question once Unity fixed it.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.