Files
godot-demo-projects/3d/platformer/coin/coin.gd
2025-10-11 05:03:59 -07:00

14 lines
342 B
GDScript

extends Area3D
var taken: bool = false
func _on_coin_body_enter(body: Node) -> void:
if not taken and body is Player:
$Animation.play(&"take")
taken = true
# We've already checked whether the colliding body is a Player, which has a `coins` property.
# As a result, we can safely increment its `coins` property.
body.coins += 1