format_shaders/pas_touche/inter_exo/lana_exo2.gd
2025-05-15 14:28:08 +02:00

18 lines
433 B
GDScript

extends CharacterBody2D
class_name LanaExo2
@export var speed := 100.0
@export var gravity := 9.8
@export var jump_velocity := -400.0
func _physics_process(delta: float) -> void:
var horizontal : float = Input.get_axis("left", "right")
if not is_on_floor():
velocity.y += gravity
if Input.is_action_just_pressed("jump") && is_on_floor():
velocity.y += jump_velocity
velocity.x = horizontal * speed
move_and_slide()