Some Player.gd cleanup.
parent
e19f7733c3
commit
2b4f4d5419
32
Player.gd
32
Player.gd
|
@ -98,12 +98,12 @@ remote func walk(direction: Vector2):
|
||||||
velocity.z = lerp(velocity.z, - walkVelocity.rotated(- self.rotation.y).x, interpolation)
|
velocity.z = lerp(velocity.z, - walkVelocity.rotated(- self.rotation.y).x, interpolation)
|
||||||
|
|
||||||
if walkVelocity.length() > 0 and is_on_floor():
|
if walkVelocity.length() > 0 and is_on_floor():
|
||||||
$Sounds/Footsteps.rpc("play")
|
$Sounds/Footsteps.play()
|
||||||
#
|
#
|
||||||
remote func jump():
|
remote func jump():
|
||||||
if is_on_floor():
|
if is_on_floor():
|
||||||
velocity.y = JUMP_VELOCITY
|
velocity.y = JUMP_VELOCITY
|
||||||
$Sounds/Jump.rpc("play")
|
$Sounds/Jump.play()
|
||||||
|
|
||||||
remote func mouselook_abs(x, y):
|
remote func mouselook_abs(x, y):
|
||||||
camera.rotation.x = x
|
camera.rotation.x = x
|
||||||
|
@ -162,7 +162,7 @@ master func on_hit(damage, location):
|
||||||
|
|
||||||
rpc("blood_splatter", location)
|
rpc("blood_splatter", location)
|
||||||
|
|
||||||
if health <= 0 and not is_dead:
|
if health <= 0:
|
||||||
rpc("kill")
|
rpc("kill")
|
||||||
$Sounds/Death.play()
|
$Sounds/Death.play()
|
||||||
else:
|
else:
|
||||||
|
@ -177,24 +177,45 @@ master func kill():
|
||||||
if is_dead:
|
if is_dead:
|
||||||
return
|
return
|
||||||
|
|
||||||
|
#print ("kill")
|
||||||
is_dead = true
|
is_dead = true
|
||||||
|
|
||||||
|
|
||||||
|
#print ("set as dead")
|
||||||
|
|
||||||
health = 0
|
health = 0
|
||||||
|
#print ("health:", health)
|
||||||
|
|
||||||
$CollisionShapeBody.disabled = true
|
$CollisionShapeBody.disabled = true
|
||||||
$CollisionShapeFeet.disabled = true
|
$CollisionShapeFeet.disabled = true
|
||||||
|
|
||||||
|
#print ("collision disabled")
|
||||||
|
|
||||||
|
# spawn gibs
|
||||||
|
|
||||||
var gibs = $Player/Gibs.duplicate()
|
var gibs = $Player/Gibs.duplicate()
|
||||||
get_tree().root.add_child(gibs)
|
get_tree().root.add_child(gibs)
|
||||||
gibs.global_transform = global_transform
|
gibs.global_transform = global_transform
|
||||||
gibs.show()
|
gibs.show()
|
||||||
|
|
||||||
|
#print ("gibs spawned")
|
||||||
|
|
||||||
# enable the ragdoll colliders
|
# enable the ragdoll colliders
|
||||||
for i in gibs.get_children():
|
for i in gibs.get_children():
|
||||||
i.get_child(1).disabled = false
|
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")
|
yield(get_tree().create_timer(3), "timeout")
|
||||||
|
|
||||||
|
|
||||||
$MeshInstance.show()
|
$MeshInstance.show()
|
||||||
spawn()
|
spawn()
|
||||||
|
|
||||||
|
@ -206,11 +227,6 @@ master func kill():
|
||||||
|
|
||||||
gibs.queue_free()
|
gibs.queue_free()
|
||||||
|
|
||||||
func despawn():
|
|
||||||
$MeshInstance.hide()
|
|
||||||
$Camera/Hand.hide()
|
|
||||||
$CrosshairContainer.hide()
|
|
||||||
|
|
||||||
func spawn():
|
func spawn():
|
||||||
is_dead = false
|
is_dead = false
|
||||||
health = 150
|
health = 150
|
||||||
|
|
Reference in New Issue