15 lines
248 B
GDScript3
15 lines
248 B
GDScript3
|
extends CharacterBody2D
|
||
|
|
||
|
@export var speed = 200;
|
||
|
@export var gravity = 50;
|
||
|
|
||
|
var direction = 1;
|
||
|
|
||
|
|
||
|
func _physics_process(delta):
|
||
|
if is_on_wall():
|
||
|
direction = direction * -1
|
||
|
velocity.x = direction * speed
|
||
|
velocity.y += gravity
|
||
|
move_and_slide()
|