[BUG] Why does AnimatorMonitor check Ability float != -1.

DankP3

Active member
1. Character controller variant (Ultimate Character Controller, First Person Controller, etc).
UCC 3.0.10; UNITY 2021.3.19f1

2. Unity version (include which SRP, beta Unity versions aren't supported)
URP

3. Bug description
I cannot set the AbilityFloat to -1 (e.g. if using an axis input). It seems the code in AnimatorMonitor checks this and prevents it (I assume a copy-paste error or is there a reason for this?):

line 1131:
Code:
for (int i = 0; i < m_CharacterLocomotion.ActiveAbilityCount; ++i) {
                if (setAbilityIndex && m_CharacterLocomotion.ActiveAbilities[i].AbilityIndexParameter != -1) {
                    abilityIndex = m_CharacterLocomotion.ActiveAbilities[i].AbilityIndexParameter;
                    setAbilityIndex = false;
                }
                if (setStateIndex && m_CharacterLocomotion.ActiveAbilities[i].AbilityIntData != -1) {
                    intData = m_CharacterLocomotion.ActiveAbilities[i].AbilityIntData;
                    setStateIndex = false;
                }
                if (setAbilityFloatData && m_CharacterLocomotion.ActiveAbilities[i].AbilityFloatData != -1) {
                    floatData = m_CharacterLocomotion.ActiveAbilities[i].AbilityFloatData;
                    setAbilityFloatData = false;
                }
            }

4. Steps to reproduce
Simply try setting the float to -1 in an ability override of the AbilityFloatData.
Setting to -0.9 works fine, for example.

5. The full error message (if any)
N/A
 
I will take a closer look at that code. -1 is normally used as a special case but I'm not sure if it's necessary for AbilityFloatData.
 
After looking into it we do need some sort of a magic number to prevent the AbilityFloatData from being set when the ability doesn't actually use it, but that magic number doesn't have to be -1. I'll change it to float.NegativeInfinity so it won't get in the way of more reasonable numbers. I'll do the same with AbilityIntData.
 
Changing the -1 on the IntData may break things for users as I sense people have adopted that as a way to not use IntData... but can't be sure. The float change makes sense to me, thank you.
 
Nice catch, one more thing ability float data can reach -1. Unsure why I didn't mention this already as I did in fact note it. -1 should not be used for ability float either I think, but honestly has not given me issues as of yet. I just assume it is not logical.
 
Top