Player cant go up a slope (ramp) or the speed isnt the same on a slope

Hi guys, so im working on a skate game and put a ramp to test on it, the problem is that the player slows down when going up to the point it gets stuck on the ramp, this is how i have it set up:
image

and this is my player settings

im not sure whats the problem is, i just want the player speed to stay the same when going up and down the ramp.

Iam using Godot 4.4, and here is what i tried:

  • i already tried playing with physical material

  • i tried playing with gravity and even completely removed it from my script, but still same result

  • played with some gravity settings but im not sure what they all do so maybe i missed something

Here is my movement code

func _physics_process(delta):
	
	if not is_on_floor():
		velocity.y -= gravity * delta
	
		# Handle jump
	if Input.is_action_just_pressed("jump") and is_on_floor():
		velocity.y = JUMP_VELOCITY
	
	# Get input and camera target
	var input_dir = Input.get_vector("right", "left", "backward", "forward")
	if camera_target:
		camera_T = camera_target.global_transform.basis.get_euler().y
	else:
		return
	
	if not lock_movement:
		# Rotate player to face camera direction
		var target_direction = (Vector3(input_dir.x, 0, input_dir.y)).rotated(Vector3.UP, camera_T).normalized()
		if target_direction != Vector3.ZERO:
			var target_angle = atan2(target_direction.x, target_direction.z)
			rotation.y = lerp_angle(rotation.y, target_angle, turn_speed * delta)
		
		# Handle movement - ONLY in character's forward direction
		if input_dir != Vector2.ZERO:
			
			# Move in character's current facing direction
			var forward_dir = transform.basis.z
			velocity.x = forward_dir.x * player_speed 
			velocity.z = forward_dir.z * player_speed 
		else:
			# Decelerate when no input
			velocity.x = move_toward(velocity.x, 0, 8 * delta)
			velocity.z = move_toward(velocity.z, 0, 8 * delta)
	
	move_and_slide()

Change the physics material on your ramp. Change the gravity in your game. Change the way you’re passing gravity to the player. You’re complaining that the physics engine is working. So tweak it until it does what you want it to do.

thank you, but i wouldnt post here if i didnt try a lot of things, most of what you said i already played with and for some reason got the same result, i can play more with gravity thanks for pointing that out, i will try to get it to work :slight_smile:

Ok, so then you should say that in the initial post. If you want help, it is common courtesy to post the version of Godot you are using, what your problem is, what you already tried to fix it, and any code that might be relevant.

You replying to my reply saying you already did that says to me that you don’t respect other people’s time. Everyone replying to help you is volunteering their own time. Please try to respect it.

BTW, your name is very suspect. If you are an AI, you shouldn’t be posting here. If you are a real person you picked a really bad handle.

2 Likes

I understand and sorry about that, not trying to be rude or anything im new here so not sure how things work and thanks for telling me, i will edit my post to say what you pointed out.

about my name its the short name of my family name lol might have to change my name to avoid that

1 Like

I appreciate the apology.

1 Like

thanks for telling me, just updated the post :slight_smile:

so it was working all along with the setting character body 3d floor settings called constant speed, the problem was caused by me trying to align the character to the ramp floor normal which ruined my movement and the physics. So i decided to just align the character model to the floor not the actual player it self since that had no problems on the slope.

2 Likes

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