39 lines
1.3 KiB
GDScript
39 lines
1.3 KiB
GDScript
extends Node3D
|
|
class_name CharacterWrapper
|
|
|
|
@export var die_script: GDScript = null
|
|
@export var owner_placeholder: Node3D = null
|
|
|
|
# Called when the node enters the scene tree for the first time.
|
|
func _ready() -> void:
|
|
# Characters should be always controlled by the server and synced accross client
|
|
# The owner should be responsible for the syncronization, since this node is
|
|
# just a dummy that is following the controller
|
|
#set_multiplayer_authority(1)
|
|
|
|
|
|
pass # Replace with function body.
|
|
func _process(delta: float) -> void:
|
|
set_multiplayer_authority(multiplayer.get_unique_id())
|
|
if owner_placeholder:
|
|
global_transform = owner_placeholder.global_transform
|
|
global_rotation = owner_placeholder.global_rotation
|
|
# Set the owner placeholder, so the characters can send the requests to a node
|
|
# it depends on
|
|
func set_owner_placeholder(owner: Node3D):
|
|
owner_placeholder = owner
|
|
|
|
func die():
|
|
push_warning("TODO: Implement ragdoll kind of dying and respawn character as an object")
|
|
queue_free()
|
|
|
|
|
|
func _on_area_body_part_hit(damage: int) -> void:
|
|
# The owner node should be aware of how to take damage, so we need to
|
|
# pass the value.
|
|
if owner_placeholder:
|
|
if owner_placeholder.has_method("take_damage"):
|
|
owner_placeholder.take_damage(damage)
|
|
else:
|
|
push_warning("Node doesn't know how to take the damage")
|