Add multiplayer damage system and ragdolls
This commit is contained in:
@ -1,8 +1,11 @@
|
||||
extends Node3D
|
||||
|
||||
|
||||
var owner_placeholder: CharacterBody3D = null
|
||||
# Called when the node enters the scene tree for the first time.
|
||||
func _ready() -> void:
|
||||
$Body/Armature/Skeleton3D.physical_bones_start_simulation()
|
||||
owner_placeholder = _get_owner()
|
||||
pass # Replace with function body.
|
||||
|
||||
|
||||
@ -12,5 +15,27 @@ func _process(delta: float) -> void:
|
||||
|
||||
|
||||
func _on_head_collision_body_part_hit(dam: Variant) -> void:
|
||||
print("head is hit")
|
||||
#print("head is hit" + str(dam))
|
||||
#print(owner_placeholder)
|
||||
#if owner_placeholder.has_method("take_damage"):
|
||||
if owner_placeholder:
|
||||
owner_placeholder.take_damage(dam)
|
||||
pass # Replace with function body.
|
||||
|
||||
func _get_owner() -> CharacterBody3D:
|
||||
var owner_placeholder := find_parent("PlayerPlaceholder*")
|
||||
return owner_placeholder
|
||||
|
||||
func die():
|
||||
for child in $Body/Armature/Skeleton3D/PhysicalBoneSimulator3D.get_children():
|
||||
if child is PhysicalBone3D:
|
||||
child.collision_layer = 1
|
||||
child.collision_mask = 1
|
||||
$Body/Armature/Skeleton3D.physical_bones_stop_simulation()
|
||||
$Body/Armature/Skeleton3D/PhysicalBoneSimulator3D.physical_bones_start_simulation()
|
||||
|
||||
func make_invisible():
|
||||
$Body/Armature/Skeleton3D/Alpha_Joints.set_layer_mask_value(1, false)
|
||||
$Body/Armature/Skeleton3D/Alpha_Surface.set_layer_mask_value(1, false)
|
||||
$Body/Armature/Skeleton3D/Alpha_Joints.set_layer_mask_value(2, true)
|
||||
$Body/Armature/Skeleton3D/Alpha_Surface.set_layer_mask_value(2, true)
|
||||
|
Reference in New Issue
Block a user