Ive got the code

``````if is_on_floor():
if Input. is_action_just_pressed("ui_up"):
motion.y = -550
else:
if motion.y < 0:
\$player.play("jump")
else:
\$player.play("fall")
move_and_slide(motion, UP)
``````

Point is my player is jumping in slow motion. His time in the air is way to long and he can jump absurd distances. how do I make it better?

in Engine

`Motion.y` needs to be increased back up to zero and this would be your gravity amount.

``````else:
#other code
motion.y += gravity_amount_variable
``````

If it still jumps too high set the initial amount for `motion.y` higher.

by (3,227 points)

well now it dosent jump at all! is my gravity to high?

yES that was it thank you!

Hello again! Your tip helps with the character falling. I was wandering if you know what I can do to make him go up in a natural way. what i mean is, when hes jumping hes going up with a constant speed. It would be much better if he started fast and the slowed down ONLY when he reaches max altitude! Thank you!

The easiest way would be to use yield to wait until it gets to max altitude then have the gravity take effect, the gravity amount would have to be increased quite a bit though.

You can use the desmos site app and some basic movement functions:
`V = V0 + at`
`y = v0*t + 0.5a*t²`
when `V`(velocity upwards) reaches 0 it means the body is at the peak of the jump, and using the second equation you can find the height it will jump.

just in case: `y` and `v` will be the Y axis and `t` will be the X axis, `V0` and `a` are constants,`V0` is the starting velocity(aka `jump_force`) and `a` is the acceleration(aka `gravity`)

by (1,196 points)

yea I think you explained ok but I dont know how to use that.
do I like. Put it i my code?

Assuming you code(jump part) is basically around a line like this:
`velocity.y = -jump_force`
then you can use a graph visualizer(desmos) in order to see the result of the jump(as for height and time in the air)

EDIT:
https://www.desmos.com/calculator/qtufn5uab0
`v` is the initial jump(the -550 in your code)
`a` is the gravity(needs to be less than 0)

do note that godot's y axis goes down for positive and desmos's y axis goes up for positive

Indeed that is usefull. But being a newb i cant use it that well yet.
What i want to do, as stated above, is:
"when hes jumping hes going up with a constant speed. It would be much better if he started fast and the slowed down ONLY when he reaches max altitude!"
If you could help me with this I would be very thankfull!
Thank you for your help until now!

Edit:
My gravity is 7 and because the negative numbers go up it cant be less then 0
I'll just show you

``````extends KinematicBody2D
const UP = Vector2(0, -100)
const ACCELERATION = 500
const MAX_SPEED = 800
var motion = Vector2()
var GRAVITY= 20

func _physics_process(delta):
var FRICTION = false
if Input. is_action_pressed("ui_right"):
motion.x = min(motion.x + ACCELERATION, MAX_SPEED)
\$player.flip_h = false
\$player.play("default")
elif Input. is_action_pressed("ui_left"):
motion.x = max(motion.x - ACCELERATION, -MAX_SPEED)
\$player.flip_h = true

\$player.play("default")
else:
motion.x = lerp(motion.x, 0, 0.1)
FRICTION = false
\$player.play("default")
motion.y += 7
if is_on_floor():
if Input. is_action_just_pressed("ui_up"):
motion.y = -450
else:
if motion.y < 0:
\$player.play("jump")
else:
\$player.play("fall")
motion.y += GRAVITY
move_and_slide(motion, UP)
pass
``````

Trying to understand what you want to do, sounds like you want to have a constant speed going upwards and when he reaches max altitude he will stop and fall.

that sounds really clanky if i got it right