Possible missing call to Mathf.Abs

kafukafu

New member
Please corret me if I'm wrong, but it appears that there is missing call to Mathf.Abs in UnityInput.cs, which might cause problems when m_Input.GetAxisRaw(name) returns -1 ? see patch below:
--- a/Assets/Opsive/Shared/Input/UnityInput.cs
+++ b/Assets/Opsive/Shared/Input/UnityInput.cs
@@ -234,7 +234,7 @@ namespace Opsive.Shared.Input
m_ToAddJoystickDownSet.Add(name);
return false;
}
- if (m_JoystickDownSet != null && m_JoystickDownSet.Contains(name) && m_Input.GetAxisRaw(name) < m_JoystickUpThreshold) {
+ if (m_JoystickDownSet != null && m_JoystickDownSet.Contains(name) && Mathf.Abs(m_Input.GetAxisRaw(name)) < m_JoystickUpThreshold) {
return true;
}
return false;
 
Why do you think this is an error?
Joystick Down is true when GetAxisRaw is smaller than the m_joystickUpThreshold.
if the threshold is 0 any number under 0 will be considered joystick down
 
Hi, what I meant is GetAixRaw could return -1, and -1 means the joystick is still up. (for example, some axis on xbox360 controller work this way)

while here, the comparison -1 < 1 will return true, the code will think the joystick is down. But it's still up. So I figured you need to use Abs here.
 
And if you look at the other places in the same code, you used Abs there but not here, so I figured this could be some inconsistency or overlook
 
Well turns out you were right. Great catch!
We'll fix that in the next update, thank you for letting us know about it
 
Top