#Alright Why do I have a Double Jump XDDD
1 messages · Page 1 of 1 (latest)
I was trying to implement jump buffering into my game
and it worked
but I realized that I had double jump
and I thought it's smth with the jump buffer
but when I deleted it, the double jump was still there
extends CharacterBody2D
const SPEED = 130.0
const JUMP_VELOCITY = -300.0
#Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/2d/default_gravity")
var jump_timer = 0.0
@onready var animated_sprite = $AnimatedSprite2D
@onready var coyote_timer = $CoyoteTimer
func _physics_process(delta):
#Add the gravity.
if not is_on_floor():
velocity.y += gravity * delta
#Handle jump.
#if Input.is_action_just_pressed("jump"):
#jump_timer = 0.1
#jump_timer -= delta
#\|/jump_timer > 0
if Input.is_action_just_pressed("jump") and (is_on_floor() || !coyote_timer.is_stopped()):
#jump_timer = 0.0
velocity.y = JUMP_VELOCITY
coyote_timer.stop()
#Get the input direction: 1, 0, -1
var direction = Input.get_axis("move_left", "move_right")
#Flip sprite
if direction > 0:
animated_sprite.flip_h = false
if direction < 0:
animated_sprite.flip_h = true
#Play animations
if is_on_floor():
if direction == 0:
animated_sprite.play("idle")
else:
animated_sprite.play("run")
else:
animated_sprite.play("jump")
#Apply movement
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
#Move and slide
var was_on_floor = is_on_floor()
move_and_slide()
#Coyote Timing
if was_on_floor && !is_on_floor():
coyote_timer.start()
here is the code
and under the handle jump hashtag there is the code that would be there
and the "jump_timer > 0" would be insted "Input.is_action_just_pressed("jump")"
I just hashtagged it so you can see that's it's not jump buffers problem
- player jumps -> stop coyote timer
- was_on_floor = true
- move_and_slide() means you're off the floor
- if was_on_floor & !is_on_floor() -> start timer ... can jump after leaving the ground
AKA you can set was_on_floor to false instead when you jump
what

I understood nothing
idk are you telling me what to do or what not to do
ehhh