I am currently working on a first person platformer for fun. I have made my character movement, and it's working fine, but when I try going up slopes that are close to the max angle that the character can walk on, it sometimes collides with something and either stops the character slowly, or slows him down and pushes him to the side.

I'm thinking this is due to my movement script that I might've messed up somehow, or the slope itself has faulty collision, or even something else. I already tried deleting and modifying the slope a number of times, but I get the same result.

The slope itself is a CSGPolygon3D with the points moved to make a slope. There are probably better ways to make slopes, but I simply wanted something quick to test my movement script.

Now I could simply decide to never use slopes that are close to the maximum angle allowed, and I will probably do that if I can't find a solution, but I don't want to be restricted by this and I don't know if this error occurs with less angled slopes but simply more rarely.

Here is the code :

extends CharacterBody3D

#movement variables
@export var speed := 9
@export var sprint_speed := 12
@export var acceleration := 10
@export var air_acceleration := 4
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@export var fall_acceleration := 4
@export var jump_force := 12

#camera variables
@onready var camera := $Camera3D
@onready var move_speed_label := $Camera3D/PlayerUi/GameInfo/PlayerSpeed/MoveSpeed
@onready var fps_counter := $Camera3D/PlayerUi/GameInfo/FpsCounter
@export var camera_sensitivity := 0.25
@export var camera_minimum_clamp := -90
@export var camera_maximum_clamp := 90

var velocity_value := Vector3.ZERO
var collision_info

#capture mouse
func _ready() -> void:
	Input.mouse_mode = Input.MOUSE_MODE_CAPTURED

#mouse inputs
func _input(event: InputEvent) -> void:
	if event is InputEventMouseMotion:
		rotate_y(event.relative.x * camera_sensitivity * -0.01)
		camera.rotate_x(event.relative.y * camera_sensitivity * -0.01)
		camera.rotation.x = clamp(camera.rotation.x, deg_to_rad(camera_minimum_clamp), deg_to_rad(camera_maximum_clamp))

#ui stats
func _process(_delta: float) -> void:
	velocity_value.y = 0
	move_speed_label.text = "Speed : " + "%.2f" % (velocity_value.length())
	fps_counter.text = "Fps : " + str(Engine.get_frames_per_second())

#player mopvement
func _physics_process(delta: float) -> void:
	var input_direction := Vector3.ZERO

	#get inputs
	input_direction.x = Input.get_action_strength("move_right") - Input.get_action_strength("move_left")
	input_direction.z = Input.get_action_strength("move_backward") - Input.get_action_strength("move_forward")
	
	var direction = (transform.basis * Vector3(input_direction.x, 0, input_direction.z)).normalized()
	
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = jump_force 
	
	if direction != Vector3.ZERO:
		$Character.look_at(position + direction, Vector3.UP)
	
	#player movement velocity
	if Input.is_action_pressed("sprint"):
		velocity.x = lerp(velocity.x, direction.x * sprint_speed, acceleration * delta)
		velocity.z = lerp(velocity.z, direction.z * sprint_speed, acceleration * delta)
	elif not is_on_floor():
		velocity.x = lerp(velocity.x, direction.x * speed, air_acceleration * delta)
		velocity.z = lerp(velocity.z, direction.z * speed, air_acceleration * delta)
	else:
		velocity.x = lerp(velocity.x, direction.x * speed, acceleration * delta)
		velocity.z = lerp(velocity.z, direction.z * speed, acceleration * delta)
	
	#falling velocity
	if not is_on_floor():
		velocity.y = lerp(velocity.y, velocity.y - (gravity), fall_acceleration * delta)
	
	velocity_value = velocity
	move_and_slide()

Here is a clip showing the error :
https://youtu.be/1emxFjfNZvM

Any feedback you have about my code is also appreciated, I made it with my general knowledge of programming and a mix of random sources, so I'm sure there are a couple of things that I am doing wrong.

Also, if you need anything else, simply tell me and I'll add it to this post.

    walvie I don't know why the code simply doesn't want to show properly

    It is necessary to set ``` at the beginning and end of the code. The single symbol (`) is for placing the code in the text.

    code

    text code text

    walvie …but when I try going up slopes that are close to the max angle that the character can walk on, it sometimes collides with something and either stops the character slowly, or slows him down and pushes him to the side.

    Could your problem be related to this one?

      Tomcat Could your problem be related to this one?

      It could be if the slope isn't actually flat, but I don't know how to check that. It might also not be the same problem because I didn't import the model from blender.

      Could you tell me how to check if the slope is completely flat?

        walvie Could you tell me how to check if the slope is completely flat?

        If the terrain is not imported, the problem is probably something else.

        Unfortunately, I can hardly tell you any more. Just saw a similar, at first glance, problem. 🙁