Im trying to make a basic endless runner, however my character wont jump, Code:
extends KinematicBody2D
#movement speed
const SPEED = 200
const GRAVITY = 10
const JUMP_POWER = -250
const FLOOR = Vector2(0, -1)
var velocity = Vector2()
func _physics_process(delta):
velocity.x = SPEED
if Input.is_action_just_pressed("ui-up"):
velocity.y = -250
print("jumped")
velocity.y += GRAVITY
velocity = move_and_slide(velocity, FLOOR)
The character moves right continuously like he's supposed to and gravity works fine. Even if i remove the condition: if Input.is_action_just_pressed("ui-up"): the jump mechanic works and the character floats. As well as this, I have removed velocity.x = SPEED to see if that was the problem and it wasn't. I've checked the input map to ensure that space and the up arrow key are binded to "ui-up" and they both are. No errors occur so the only thing i can think of is that the condition for some reason is never True. I'm really confused as to why this isn't working and would appreciate any help.