0 votes

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)
Godot version 3.3.2
in Engine by (64 points)

1 Answer

0 votes
Best answer

i had that issue what i do is set the snap vector to 0 in process and change it onfloor and !jump so it kinda disables the snapvector 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...
by (430 points)
edited by
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.