Advertisement
chris33556

updated_oildrum_test

Aug 7th, 2022
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 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: Particles = $Particles
  10.  
  11.  
  12. func handle_hit(damage: int):
  13. health -= damage
  14. print("enemy was hit!, current health: " + str(health))
  15. if health <= 20:
  16. $oildrumDamage.play("oildrum_damage_1")
  17. if health <= 10:
  18. $oildrumDamage.play("oildrum_damage_2")
  19. if health <= 0:
  20. destroy()
  21.  
  22.  
  23. func destroy() -> void:
  24. $oildrumDamage.visible = false
  25. particles.emitting = true
  26. yield(get_tree().create_timer(particles.lifetime, false), "timeout")
  27. queue_free()
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement