18 lines
433 B
GDScript
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()
|