Hi there, here is my jump function.
I'm having a very strange issue where if my character falls from a very tall height, he will fall, but stop in mid air, then continue to fall. I'm using moveandslide in my physics process function if that helps.
Oddly enough, I have a friction function that doesn't seem to apply friction either. However I've disabled it to make sure that wasn't the cause, and it wasn't.
PS. I know I have two isonfloor checks, I'll fix that later, but at the moment, that isn't the issue either. I've disabled the second one and I still had the issue.
I thought it might be the delta but I'm not entirely sure how to use it.
if is_dead == false:
jumps_left = 2
jumps_left = 1
if Input.is_action_just_pressed("up") and jumps_left > 0:
#if I'm falling - ignore fall velocity
if velocity.y > 0:
velocity.y = 0
velocity.y = JUMP_POWER
jumps_left -= 1
if not is_on_floor() and next_to_left_wall():
velocity.x += JUMP_POWER
if not is_on_floor() and next_to_right_wall():
velocity.x -= JUMP_POWER
#if still jumping, start to fall
if Input.is_action_just_released("up") and velocity.y < 0:
velocity.y *= FALL_SPEED
on_ground = false
if on_ground == false:
is_attacking = false
on_ground = true
if is_attacking == false:
on_ground = false
velocity = Vector2()
Edit: Hi guys, I've done some further testing and have found that when it reaches a specific number (1953 or 1955), for some reason it resets to 1 immediately after, which is causing me to suddenly stop in mid air for a second.
EDIT: FOUND THE ISSUE!!!
I have a gravity function (that I copy and pasted from a tutorial) that clamps the falling speed if it hits 2000. Ha....
if not dashing:
velocity.y += GRAVITY
if velocity.y > 2000:
velocity.y = 0 #clamp falling speed
if next_to_wall() and velocity.y > MAX_WALL_SLIDE_SPEED and (Input.is_action_pressed("right") or Input.is_action_pressed("left")):
velocity.y = MAX_WALL_SLIDE_SPEED #wall slide