First commit
This commit is contained in:
15
scripts/player.gd
Normal file
15
scripts/player.gd
Normal file
@@ -0,0 +1,15 @@
|
||||
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()
|
||||
Reference in New Issue
Block a user