# I am having trouble implementing a Varying Jump Height Mechanic

Attention Topic was automatically imported from the old Question2Answer platform.
``````Hi, first of all I want to mention that English is not my mother tongue, and that I am only 16, so I don't have any prior programming experience, although, I understand what certain thing do :)))

I am working on my first video game, and I want to implement a "Varying Jump Height Mechanic" for my character. I try to make the controls feel like a hybrid between "Super Mario Bros 1, Super Castlevania IV, Super Meat-Boy and Mega Man 7"

For now, I managed to give the player the desired air control, however, without having   the possibility to control the height of the jump, the movement will feel quite sloppy.
``````

One more thing before I give you the script, all the sprites are placeholders for now if that has to do with anything.

extends KinematicBody2D

const SPEED = 125
const GRAVITY = 18
const JUMP_POWER = -325
const FLOOR = Vector2(0, -1)

var velocity = Vector2()

var on_ground = false

func _physics_process(delta):

``````if is_dead == false:
``````
``````	 if Input. is_action_pressed("ui_right"):
velocity.x = SPEED
\$AnimatedSprite.play("run")
\$AnimatedSprite.flip_h = true
if sign(\$Position2D.position.x) == -1:
\$Position2D.position.x *= -1

elif Input. is_action_pressed("ui_left"):
velocity.x = -SPEED
\$AnimatedSprite.play("run")
\$AnimatedSprite.flip_h = false
if sign(\$Position2D.position.x) == 1:
\$Position2D.position.x *= -1

else:
velocity.x = 0
if on_ground == true:
\$AnimatedSprite.play("idle")

if Input. is_action_pressed("ui_up"):
if on_ground == true:
velocity.y = JUMP_POWER
on_ground = false

if Input. is_action_just_pressed("ui_focus_next"):
var fireball = FIREBALL.instance()
if sign(\$Position2D.position.x) == 1:
fireball.set_fireball_direction(1)
else:
fireball.set_fireball_direction(-1)

fireball.position = \$Position2D.global_position

velocity.y += GRAVITY

if is_on_floor():
on_ground = true
else:
on_ground = false
if velocity.y < 0:
\$AnimatedSprite.play("jump")
else:
\$AnimatedSprite.play("fall")

velocity = move_and_slide(velocity, FLOOR)

if get_slide_count() > 0:
for i in range(get_slide_count()):
if "Enemy" in get_slide_collision(i).collider.name:

if Input. is_action_just_pressed("ui_cancel"):
get_tree().change_scene("titlescreen.tscn")
``````

`````` I hope that I can find someone that is kind, and patient enough to help me with this issue, I would do it myself, but like I said I am 16 so I do not have any experience.