Prepare the object
Create a Cell named Coin in your World. Give it a distinct name so the lookup cannot select a different object.
Create and save scripts/coin.aeo with this code:
const coins = find("Coin")
if basket.len(coins) > 0 {
const coin = coins[0]
coin.on_touch = fn(thing) {
const player_entity = get_entity("Player")
if thing != player_entity {
return
}
coin.visible = false
coin.solid = false
debug.log("Coin collected")
}
}
Test
Start Play and touch the Coin with the Player. The Coin disappears and Output prints Coin collected.
The callback checks the touching object. Other Entities should not collect the Coin.
Reset
Stop Play and start again. The authored Coin returns. See Events for callback behavior and Finding Objects for lookup choices.