Godot Version
4.3
Question
im making a jetpack joyride clone game and im working on the jetpack rn im trying to make the physics more like jetpack joyride since my current ones dont carry momentum as soon as you stop using jetpack it just falls at max speed which isnt as fun so I took this
velocity += get_gravity() * delta
and made turned it into this
if Input.is_action_just_pressed("ui_accept"):
velocity.y = JUMP_VELOCITY
if Input.is_action_just_released("ui_accept"):
velocity += get_gravity() * delta
but it never falls and just keeps going up with jump key released this is my full code can anyone help?`
extends CharacterBody2D
const SPEED = 300
const JUMP_VELOCITY = -400.0
const gravity = 500
var direction = 1
#469 from players position
func _physics_process(delta: float) -> void:
Global.player_position = global_position
if !is_on_floor():
$"Character Sprite".play("Flying")
else:
$"Character Sprite".play("idle")
# Handle jump.
if Input.is_action_just_pressed("ui_accept"):
velocity.y = JUMP_VELOCITY
if Input.is_action_just_released("ui_accept"):
velocity += get_gravity() * delta
# Get the input direction and handle the movement/deceleration.
# As good practice, you should replace UI actions with custom gameplay actions.
if direction:
velocity.x = direction * SPEED
else:
velocity.x = move_toward(velocity.x, 0, SPEED)
move_and_slide()