killbox/godot/scenes/characters/character_wrapper.gd

39 lines
1.3 KiB
GDScript3
Raw Normal View History

2025-02-09 15:58:32 +00:00
extends Node3D
2025-02-06 08:56:39 +00:00
class_name CharacterWrapper
@export var die_script: GDScript = null
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
2025-02-09 15:58:32 +00:00
#set_multiplayer_authority(1)
2025-02-06 08:56:39 +00:00
pass # Replace with function body.
2025-02-09 15:58:32 +00:00
func _process(delta: float) -> void:
2025-02-09 16:00:09 +00:00
set_multiplayer_authority(multiplayer.get_unique_id())
2025-02-09 15:58:32 +00:00
if owner_placeholder:
global_transform = owner_placeholder.shared_node.global_transform
global_rotation = owner_placeholder.shared_node.global_rotation
2025-02-06 08:56:39 +00:00
# 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
2025-02-08 18:30:32 +00:00
func die():
2025-02-06 08:56:39 +00:00
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")