Made footsteps not play when the player is killed, and always play the kill sound when dying

Made footsteps not play when the player is stuck against a wall. Made
the death sound play when dying, not when taking  hit AND dying, so
killfloor also triggers it.
godot4-port
Jan Heemstra 2020-09-29 00:35:12 +02:00
parent 15f9859b35
commit 85788d9c5c
1 changed files with 7 additions and 3 deletions

View File

@ -102,8 +102,7 @@ remote func walk(direction: Vector2):
velocity.x = lerp(velocity.x, walkVelocity.rotated(- self.rotation.y).y, interpolation)
velocity.z = lerp(velocity.z, - walkVelocity.rotated(- self.rotation.y).x, interpolation)
if walkVelocity.length() > 0 and is_on_floor():
$Sounds/Footsteps.play()
#if walkVelocity.length() > 0 and is_on_floor():
#
remote func jump():
if is_on_floor():
@ -123,6 +122,10 @@ remote func mouselook(rel):
func motion(delta):
var slide_velocity = move_and_slide(velocity * delta, Vector3.UP, true)
if slide_velocity.length() > 2 and is_on_floor():
$Sounds/Footsteps.play()
#var slide_velocity = move_and_collide(velocity * delta, Vector3.UP)
debug.text += "\nslide_velocity: " + String( slide_velocity )
@ -170,7 +173,6 @@ master func on_hit(damage, location):
if health <= 0:
rpc("kill")
$Sounds/Death.rpc("play")
else:
$Sounds/Pain.rpc("play")
@ -183,6 +185,8 @@ master func kill():
if is_dead:
return
$Sounds/Death.rpc("play")
#print ("kill")
is_dead = true