extends CharacterBody3D
Get the gravity from the project settings to be synced with RigidBody nodes.
var gravity = ProjectSettings.get_setting("physics/3d/default_gravity")
@export var direction = 0
func _ready():
if direction:
$AnimatedSprite3d.play("walk")
if direction:
velocity.x = -1
$AnimatedSprite3d.flip_h = true
if direction:
velocity.x = 1
$AnimatedSprite3d.flip_h = true
func _physics_process(delta):
if is_on_wall():
direction = direction * -1
$AnimatedSprite3d.flip_h = not $AnimatedSprite3d.flip_h
# Add the gravity.
if not is_on_floor():
velocity.y -= gravity * delta
move_and_slide()