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")

func applygravity():
if not is
motion.y += GRAVITY
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
motion.x = 0

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

in Engine by (12 points)

1 Answer

+1 vote

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,219 points)

Wow! This completely solved my problem! It's been a whole month since I was thinking why this wasn't working just for me and now I realized it's because of me not reading the docs properly.

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.