0 votes

var motion = Vector2(0,0)

const SPEED = 500
const GRAVITY = 5
const UP = Vector2(0,-1)
const JUMP = -3000

func physicsprocess(delta):
if Input.isactionpressed("uiup"):
print("should jump but isnt")
apply
gravity()
jump()
move()
animate()
moveandslide(motion)

func applygravity():
if not is
on_floor():
motion.y += GRAVITY
else:
motion.y = GRAVITY

func move():
if Input.isactionpressed("uileft") and not Input.isactionpressed("uiright"):
motion.x = -SPEED
elif Input.isactionpressed("uiright") and not Input.isactionpressed("uileft"):
motion.x = SPEED
else:
motion.x = 0

func jump():
if Input.isactionjustpressed("uiup") and isonfloor():
motion.y = JUMP

asked Jun 16 in Projects by GH123# (12 points)

1 Answer

0 votes

Your move_and_slide doesn't have an up direction so it defaults to Vector2.ZERO. It mentions in the docs 'used to determine what is a wall and what is a floor or a ceiling'

move_and_slide(motion, Vector2.UP)
answered Jun 16 by Magso (2,711 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.