+1 vote

Movement works properly and all, but gravity that should be caused by the line
I highlithed just doesn't do anything.

extends KinematicBody2D

var motion = Vector2()

func physicsprocess(delta):
motion.y += 10

if Input.is_action_pressed("ui_right"):
    motion.x = 100
elif Input.is_action_pressed("ui_left"):
    motion.x = -100
else:
    motion.x = 0
if Input.is_action_pressed("ui_up"):
    motion.y = -100
elif Input.is_action_pressed("ui_down"):
    motion.y = 100
else:
    motion.y = 0
move_and_slide(motion)
pass
Godot version 3.3
in Engine by (19 points)

1 Answer

+1 vote
Best answer

If you aren't pressing ui_up or ui_down motion.y will be set to 0 per your else clause, overriding your motion.y += 10 at the top of _physics_process()

by (3,707 points)
selected by

Yea pretty simple. Thanks!

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.