Improved component system
This commit is contained in:
@ -1,5 +0,0 @@
|
||||
class_name Controller
|
||||
extends Node
|
||||
|
||||
## The character that we're controlling.
|
||||
@export var character: Character
|
@ -1,22 +0,0 @@
|
||||
class_name PlayerController
|
||||
extends Controller
|
||||
|
||||
var move: Vector2
|
||||
|
||||
func _unhandled_input(event):
|
||||
if Global.interacting_with_ui:
|
||||
return
|
||||
|
||||
move = Input.get_vector("move_left", "move_right", "move_forward", "move_backward")
|
||||
character.direction = (Global.camera.transform.basis * Vector3(move.x, 0, move.y))
|
||||
character.direction.y = 0
|
||||
character.direction = character.direction.normalized()
|
||||
|
||||
if event.is_action_pressed("jump"):
|
||||
character.jump()
|
||||
|
||||
if event.is_action_pressed("dash"):
|
||||
character.dash()
|
||||
|
||||
if event.is_action_pressed("attack"):
|
||||
character.attack()
|
@ -1,19 +0,0 @@
|
||||
class_name ProxyController
|
||||
extends Controller
|
||||
|
||||
## The authoritative position on the server.
|
||||
var server_position: Vector3
|
||||
|
||||
func _ready():
|
||||
server_position = character.position
|
||||
|
||||
func _process(_delta):
|
||||
var move := server_position - character.position
|
||||
move.y = 0.0
|
||||
|
||||
if move.length_squared() < 0.01:
|
||||
character.direction = Vector3.ZERO
|
||||
return
|
||||
|
||||
character.direction = Vector3(move.x, 0, move.z)
|
||||
character.direction = character.direction.normalized()
|
Reference in New Issue
Block a user