16 lines
406 B
GDScript
16 lines
406 B
GDScript
class_name Player extends CharacterBody3D
|
|
|
|
@export var speed : float = 10
|
|
@onready var body = $Body
|
|
|
|
func _enter_tree() -> void:
|
|
Game.player = self
|
|
|
|
func _physics_process(delta: float) -> void:
|
|
var dir = Input.get_vector("west", "east", "north", "south")
|
|
dir = Vector3(dir.x, 0, dir.y)
|
|
if dir.length_squared() > 0:
|
|
body.look_at(body.global_position - dir)
|
|
velocity = speed * dir
|
|
move_and_slide()
|