Godot Version

v4.2.1.stable.official [b09f793f5]

Question

I want my player to keep sliding down, but when player reaches more straight ground, he suddenly stops. I have no idea how to program it so that he would keep going, but the speed will slow down every time. Any ideas?

Code

`SPEED_MULTIPLY` is 1.0 most of the time, so count it like that, `speed` could be either 3.0, 5.0 or 8.0, but because we’re crouching to slide, it is 3.0

``````	# Get the input direction and handle the movement/deceleration.
var input_dir = Input.get_vector("left", "right", "forward", "backward")
var direction = (head.transform.basis * Vector3(input_dir.x, 0, input_dir.y)).normalized()
if is_on_floor():
if SPEED_MULTIPLY > 1.0: SPEED_MULTIPLY -= 0.05
if SPEED_MULTIPLY < 1.0: SPEED_MULTIPLY += 0.005
if direction:
velocity.x = direction.x * speed * SPEED_MULTIPLY
velocity.z = direction.z * speed * SPEED_MULTIPLY
else:
velocity.x = lerp(velocity.x, direction.x * speed * SPEED_MULTIPLY, delta * 7.0)
velocity.z = lerp(velocity.z, direction.z * speed * SPEED_MULTIPLY, delta * 7.0)

else:
velocity.x = lerp(velocity.x, direction.x * speed * SPEED_MULTIPLY, delta * 3.0)
velocity.z = lerp(velocity.z, direction.z * speed * SPEED_MULTIPLY, delta * 3.0)
move_and_slide()
``````

I’m no pro but the first thing that comes to mind is adding:

``````const MAX_SLOPE_ANGLE : int = yourintegerhere
``````

and something like:

``````vel = move_and_slide(vel,Vector3(0,1,0), 0.05, 4, deg2rad(MAX_SLOPE_ANGLE))
``````

sadly I’m not sure of how to integrate it into your current setup offhand.
hope somebody else can be more helpful.

set_wall_min_slide_angle ( float value )

Found out the problem - the code was changing the min slide angle to 50 degrees.

Note for beginners: Don’t forget to check your code FULLY, even if you’re sure this isn’t the problem, even if it’s a spaghetti code

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.