gfolf2/src/items/item/item.gd

20 lines
510 B
GDScript

class_name Item extends Node3D
## Base class for item pick-ups in the world.
signal on_collect(player: WorldPlayer)
@onready var explosion_player: AnimationPlayer = %ExplosionPlayer
func _collect(player: WorldPlayer) -> void:
# Note that this animation will call `queue_free` in 5 seconds!
explosion_player.play("explode")
on_collect.emit(player)
func _on_collection_area_body_entered(body: Node3D) -> void:
if body is GameBall:
var ball: GameBall = body
if ball.player:
_collect(ball.player)