+1 vote

gdscript: how can i create Gravity for the jump??? (KinematicBody2D)

in Engine by (103 points)

2 Answers

+1 vote

Take a look at the platformer-demo, especially Actor.gd and Player.gd. The idea is not different from other movement: you move the character each frame along a velocity-vector, so if you want your character to fall down, you just have to change the orientation of that vector. It's usually done by adding a certain weight (the gravity) to the y-direction of your velocity-vector each frame, so the character will fall faster and faster the longer it is in free fall.

by (10,267 points)
+1 vote

you can use (your velocity variable).y += (your gravity constant)

by (52 points)

where, in func physicsprocess(delta). or where??

in func _physics_process(delta)

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.