Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | GH123# |
var motion = Vector2(0,0)
const SPEED = 500
const GRAVITY = 5
const UP = Vector2(0,-1)
const JUMP = -3000
func _physics_process(delta):
if Input.is_action_pressed(“ui_up”):
print(“should jump but isnt”)
apply_gravity()
jump()
move()
animate()
move_and_slide(motion)
func apply_gravity():
if not is_on_floor():
motion.y += GRAVITY
else:
motion.y = GRAVITY
func move():
if Input.is_action_pressed(“ui_left”) and not Input.is_action_pressed(“ui_right”):
motion.x = -SPEED
elif Input.is_action_pressed(“ui_right”) and not Input.is_action_pressed(“ui_left”):
motion.x = SPEED
else:
motion.x = 0
func jump():
if Input.is_action_just_pressed(“ui_up”) and is_on_floor():
motion.y = JUMP