I am currently building a platformer game. I was attempting to use move_and_slide_with_snap for the first time and can't find it working for me. My character does snap to the ground like I expected, but I find that it still slides when it's on a slope. I think that I implemented the code properly with it.
If there is a solution I would love to hear it. What am I doing wrong?
func _physics_process(delta): var current_gravity = GRAVITY - (int(is_on_wall() and inventory.Frog) * GRAVITY/2) var current_jump_force = JUMP_FORCE var x_input = Input.get_action_strength("ui_right") - Input.get_action_strength("ui_left") if x_input != 0: motion.x += x_input * ACCELERATION * delta motion.x = clamp(motion.x, -MAX_SPEED, MAX_SPEED) else: playback.travel("Stand") if !is_on_wall(): if motion.y <= max_fall_speed: motion.y += current_gravity * delta else: if motion.y <= max_slip_speed: motion.y += current_gravity * delta if is_on_floor() or is_on_wall(): if x_input == 0: motion.x = lerp(motion.x, 0, FRICTION) if Input.is_action_just_pressed("ui_up"): var can_jump = int(inventory.Spring) motion.y = -(current_jump_force + (JUMP_FORCE / 2.5 * can_jump)) else: if Input.is_action_just_released("ui_up") and motion.y < -JUMP_FORCE/2: motion.y = -current_jump_force/2 if x_input == 0: motion.x = lerp(motion.x, 0, AIR_RESISTANCE) if !motion.y: motion = move_and_slide_with_snap(motion, Vector2.DOWN * 320, Vector2.UP, true, 1) else: motion = move_and_slide(motion, Vector2.UP)