move_and_slide_with_snap() doesn't jump

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Repertix

When using move_and_slide_with_snap() the player doesn’t jump. When using is_on_floor() doesn’t make it jump, I checked if it wasn’t detecting floor but it does, shows true when is on floor.

This is how the code looks

var snap = Vector2.DOWN * 16

if is_on_floor():
  if Input.is_action_just_pressed('jump'):
      motion.y = -jumpforce

motion = move_and_slide_with_snap(motion, snap, Vector2.UP)
:bust_in_silhouette: Reply From: vnmk8

i had that issue what i do is set the snap vector to 0 in process and change it on_floor and !jump so it kinda disables the snap_vector on jump

const SNAP_VECTOR = 20.0
func _physics_process(delta):
  var snap_vector = Vector2.ZERO
  if on_floor and !jump:
     var snap_vector = Vector2.DOWN * SNAP_VECTOR 
  move_and_slide_with_snap(motion, snap_vector, FLOOR_NORMAL, etc...