first my godot version is 4.3
my problem is the player jump in the air here is my code
extends CharacterBody2D
@onready var ray = $RayCast2D
var inputs = {
‘ui_right’ : Vector2.RIGHT,
‘ui_left’ : Vector2.LEFT,
}
func _unhandled_input(event):
for dir in inputs.keys():
if event.is_action_pressed(dir):
move(dir)
pass
func move(dir):
var vector_pos = inputs[dir] * 16
ray.target_position = vector_pos
ray.force_raycast_update()
if !ray.is_colliding():
position += vector_pos
var speed = 75.0
func _physics_process(delta):
velocity += Vector2.DOWN * 10.0 * delta
if Input.is_action_pressed("ui_up"):
velocity = Vector2.UP * 5
move_and_collide(velocity)