dbrizov / NaughtyCharacter

Third Person Controller for Unity
MIT License
988 stars 139 forks source link

Character velocity bug, when no joystick controller is plugged in (In slow-motion only) #1

Closed dbrizov closed 9 years ago

dbrizov commented 9 years ago

When in slow-motion sometimes the character's horizontal velocity goes to 0.0 for a single frame and a transition to Idle state starts. This creates an effect as if the character is faltering for a sec. When I plug in a controller before I start Unity the bug fixes. Then when I unplug the controller while the Unity Editor is running, the bug is still fixed.

Edit: I found out what the problem is. The CharacterController component internally stores the last two positions of the character and the time that was needed for the character to move from the first position to the second position. This information is enough so that the velocity of the character can be calculated. In slow motion however, these two positions sometimes are equal, because the character is moving really slowly. This way the calculated velocity results in 0.0, and the Idle animation of the character start to play for a single frame. However I don't know why this bug is present only when no joystick controller is plugged in.

dbrizov commented 9 years ago

I fixed the issue. Apparently it was bug connected with the Min Move Distance of the built-in CharacterController. The fix was just to set the property to zero.