+1 vote

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

asked Apr 11 in Engine by ManiCus (70 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.

answered Apr 11 by njamster (8,904 points)
+1 vote

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

answered Apr 11 by NotGoodatGodot (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.