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

in Projects by (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)
by (3,141 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.

Categories