forked from unfa/liblast
Some cleaning work
parent
065ae9a51a
commit
fcc5c11e4f
28
Player.gd
28
Player.gd
|
@ -162,7 +162,7 @@ master func on_hit(damage, location):
|
|||
|
||||
rpc("blood_splatter", location)
|
||||
|
||||
if health <= 0:
|
||||
if health <= 0 and not is_dead:
|
||||
rpc("kill")
|
||||
$Sounds/Death.play()
|
||||
else:
|
||||
|
@ -177,45 +177,24 @@ master func kill():
|
|||
if is_dead:
|
||||
return
|
||||
|
||||
#print ("kill")
|
||||
is_dead = true
|
||||
|
||||
|
||||
#print ("set as dead")
|
||||
|
||||
health = 0
|
||||
#print ("health:", health)
|
||||
|
||||
$CollisionShapeBody.disabled = true
|
||||
$CollisionShapeFeet.disabled = true
|
||||
|
||||
#print ("collision disabled")
|
||||
|
||||
# spawn gibs
|
||||
|
||||
var gibs = $Player/Gibs.duplicate()
|
||||
get_tree().root.add_child(gibs)
|
||||
gibs.global_transform = global_transform
|
||||
gibs.show()
|
||||
|
||||
#print ("gibs spawned")
|
||||
|
||||
# enable the ragdoll colliders
|
||||
for i in gibs.get_children():
|
||||
i.get_child(1).disabled = false
|
||||
|
||||
#print ("gibs enabled")
|
||||
|
||||
# Respawn timer
|
||||
#print ("set as dead")
|
||||
$MeshInstance.hide()
|
||||
$Camera/Hand.hide()
|
||||
$CrosshairContainer.hide()
|
||||
|
||||
|
||||
yield(get_tree().create_timer(3), "timeout")
|
||||
|
||||
|
||||
$MeshInstance.show()
|
||||
spawn()
|
||||
|
||||
|
@ -227,6 +206,11 @@ master func kill():
|
|||
|
||||
gibs.queue_free()
|
||||
|
||||
func despawn():
|
||||
$MeshInstance.hide()
|
||||
$Camera/Hand.hide()
|
||||
$CrosshairContainer.hide()
|
||||
|
||||
func spawn():
|
||||
is_dead = false
|
||||
health = 150
|
||||
|
|
Loading…
Reference in New Issue