Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Flashfast45 |
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!