generated from krampus/template-godot4
20 lines
510 B
GDScript3
20 lines
510 B
GDScript3
|
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)
|