coin.gd 322 B

12345678910111213
  1. extends Area3D
  2. var taken = false
  3. func _on_coin_body_enter(body):
  4. if not taken and body is Player:
  5. $Animation.play(&"take")
  6. taken = true
  7. # We've already checked whether the colliding body is a Player, which has a `coins` property.
  8. # As a result, we can safely increment its `coins` property.
  9. body.coins += 1