|Topic was automatically imported from the old Question2Answer platform.
I’m messing around in 3D with a modified FPS controller from the Asset Library and my gradual de-acceleration procedure is doing something confusing.
Here’s a (pastebin) link to the only code in the scene, attached to a capsule-shaped KinematicBody resting on a simple StaticBody floor plane. When I look at the output, I can see
compare_floats() being called almost constantly, but when I step through it in the debugger, I can’t make sense out of why the program flows that way (that method should only be called when testing to see if the current velocity is close enough to 0 to just set at 0 and turn the de-acceleration procedure off). It seems to illegally contradict itself by executing the code on line 77 after the
if velocity.x != 0 || velocity.z != 0: conditional. The debugger lists both of those values as 0, but the conditional still works out to
true. I’ve tried replacing the
0 integer literal with
0.0 as well, but that had the same result.
Help understanding the control flow here would be great. Any suggestions on alternative ways to de-accelerate a moving KinematicBody after the user lets go of directional inputs (and the KinematicBody is on the ground, but that’s an easy conditional to tack on) would also be helpful.