The Godot Q&A is currently undergoing maintenance!

Your ability to ask and answer questions is temporarily disabled. You can browse existing threads in read-only mode.

We are working on bringing this community platform back to its full functionality, stay tuned for updates. | Twitter

+2 votes

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
    motion.x = 0
if Input.is_action_pressed("ui_up"):
    motion.y = -100
elif Input.is_action_pressed("ui_down"):
    motion.y = 100
    motion.y = 0
Godot version 3.3
in Engine by (20 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,906 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 Frequently asked questions and 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 [email protected] with your username.