bullet.gd 509 B

1234567891011121314151617181920212223242526
  1. extends Area2D
  2. var motion = Vector2.ZERO
  3. var type = 4
  4. var id = ''
  5. var fliph = false
  6. var target = 'enemy'
  7. var dmg = 1
  8. #func _ready():
  9. # print('bullet gen...')
  10. func _physics_process(delta):
  11. global_position += (motion*delta)
  12. func _on_bullet_body_entered(collide):
  13. if collide:
  14. if collide.is_in_group(target):
  15. collide.damage(-dmg,id)
  16. # print('col enemy')
  17. queue_free()
  18. if collide.is_in_group('terrain'):
  19. queue_free()
  20. func _on_Timer_timeout():
  21. queue_free()
  22. pass # Replace with function body.