Advertisement
chris33556

oildrum script

Aug 9th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.86 KB | None | 0 0
  1. extends KinematicBody
  2.  
  3. var gravity = 9.8
  4. var jump = 5
  5. var velocity = Vector3()
  6. export (int) var health := 30
  7.  
  8. onready var animatedSprite = $AnimatedSprite3D
  9. onready var particles_top: Particles = $Particles
  10. onready var particles_bottom: Particles = $Particles2 # The second particle emitter for the bottom of the drum
  11.  
  12.  
  13. func handle_hit(damage: int):
  14. health -= damage
  15. print("enemy was hit!, current health: " + str(health))
  16. if health <= 20:
  17. $oildrumDamage.play("oildrum_damage_1")
  18. if health <= 10:
  19. $oildrumDamage.play("oildrum_damage_2")
  20. if health <= 0:
  21. destroy()
  22.  
  23.  
  24. func destroy() -> void:
  25. $oildrumDamage.visible = false
  26. particles_top.emitting = true
  27. particles_bottom.emitting = true # Need to set emiting to true for both of the particles
  28. yield(get_tree().create_timer(particles_top.lifetime, false), "timeout")
  29. queue_free()
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement