Care to show the rest of the code? Also might as well point out that you are mixing tabs and spaces for indentation in there, which is not recommended.
Double Jump Not working properly
- Edited
- Best Answerset by SleepingYellowCreature
You still haven't posted move_and_fall(). What are you using to actually move the object? You have to have move_and_slide() or move_and_slide_with_snap() in there somewhere before is_on_floor() will work.
This works for me.
extends KinematicBody2D
const GRAV = Vector2(0, 9)
const JUMP = Vector2(0, -15)
const MUL = 30
var jumps := 0
var velocity := Vector2.ZERO
func _input(event):
if event.is_action_pressed('ui_select'):
if jumps < 2:
velocity = JUMP * MUL
jumps += 1
func _process(delta):
velocity += GRAV
move_and_slide(velocity, Vector2(0, -1))
if is_on_floor():
jumps = 0
- Edited
Also, you should copy and past code onto the forum, not use screenshots. You can type 3 tildes "~~~" on a line by themselves, directly above and directly below the code text you paste for it to work on the forum.
- Edited
A simple fix is to us an integer and on action pressed. On action pressed, if jumps are greater than zero, jump and then subtract 1 from jumps. When you land on the ground, jumps is reset.
cybereality directly above and directly above the code
And directly below*