0 votes

I am making a simple platformer. It has all the basic mechanics such as running and jumping. But for some reason, it doesn't jump when moving left. It works fine for the other direction. Here is my code:

extends KinematicBody2D

const UP = Vector2(0, -1)
var jump_power = 400
var gravity = 10
var speed = 250
var motion = Vector2()

func _physics_process(delta):
    motion.y += gravity                           #Gravity!

    if Input.is_action_pressed("ui_left"):        #Slide to the left!
        motion.x = -1 * speed
    elif Input.is_action_pressed("ui_right"):     #Slide to the right!
        motion.x = 1 * speed
    else:                                         # Freeze!                               
        motion.x = 0

    if is_on_floor():                             #Jump left PLEASE!
        if Input.is_action_pressed("ui_up"):
            motion.y = -1 * jump_power

    motion = move_and_slide(motion, UP)
    pass

Thanks!

in Engine by (14 points)

1 Answer

–1 vote

Your code is fine, this is a common problem when certain keyboards don't register certain combinations. Unfortunately chances are space + left won't work on your keyboard with any game :/

by (3,201 points)
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.