Character moving/sliding without button prompt

Godot Version



my character has randomly started sliding around the map. usure of what caused this to happen any ideas ?

this is my code i have for the movement/animations

thanks in advance

Whatcha out for normalized function when there is no input. A normalized zero vector is undefined behavior.

1 Like

[quote=“gertkeno, post:3, topic:68358”]
velocity.x = lerp(0.0, velocity.x, LERP_VAL)
I really apprentice the comment but IDK what that last part means, could you explain it to me please

heya so i tried changing the value from zero and removed the normalized() but stil hasnt fixed it. sorry for all the questions im new to this

Okay I guess if the vector is completely zero it may not be a issue, I think the source code will just return zero instead of using it.

1 Like

I believe I was wrong about the lerp order, I still do not think you should use that function for this.

I believe your code should work, could you explain further what is happening? What causes this sliding? Is it like walking, only without input? Do you have to start walking to start sliding? Do you eventually slow down?

1 Like

Basically, my character is sliding left or right without any button presses or prompt to do so. This happened randomly when I was trying to set up ray cast 3D.

While checking if I could detect objects, my character immediately would slide to the left or right and fall off the edge. He doesn’t slow down,
there is no animation for the sliding, he just slides whenever I load the game.

I’ve removed the normalized function and switches around the LERP, but still getting the same effect.

1 Like

Are you using a gamepad or keyboard? If keyboard, I don’t see a problem with the code.

If gamepad, it could be a deadzone issue with the controller. This can be adjusted with the InputMap action settings.

I guess you say button prompt in the title. So I’m not sure…

Btw if also on Linux, and a laptop, the track pad may be functioning like a gamepad for Godot.

Maybe the last thing, but I doubt, is the gravity I think move and slide will use the floor collision normal to cancel out effects of the velocity increase due to gravity. But maybe it’s increasing over time?

I don’t have any other ideas, and maybe the problem is elsewhere.

sorry i relplied to the wrong post

I think the issue must stem from somewhere else then. Anything scripted or physicsy about the character’s parent?

1 Like

thats what im thinking tbh i might move on or rewrite the codes itself

i thinks so this is what i have for y

spring_arm.rotate_x(-event.relative.y * .005) line 27

velocity.y -= gravity * delta line 37

var direction = (transform.basis * Vector3(input_dir.x, 1, input_dir.y)) line 42

direction = direction.rotated(Vector3.UP, springarmpivot.rotation.y) line 43

armature.rotation.y =lerp_angle(armature.rotation.y, atan2(-velocity.x, -velocity.z), LERP_VAL) line 47

these are all my lines of code with y

Could you post the scene tree for this scene?