Skip to content

Pickup

Something to collect, with no code: coins, gems, hearts, keys. When something it accepts touches it (see Layers), it sends its Message with its Amount (a Counter adds it up), plays its Sound, spawns its Effect and disappears. Needs a collider on the same entity, usually a trigger.

Requires: Collider (usually a trigger)

Works with: Counter (adds up what’s collected (on another entity))

Each is listed as its key in the scene file and the MCP tools, then its kind of value, its default and what it does.

  • layers: text = null. The collision layers that can collect it, e.g. “Player”. Empty lets anything with a Body collect it. (Names collision layers: their names, separated by commas.) (Field: a name.)
  • message: text = “Score”. The message sent when it’s collected, with Amount as its data. Empty sends nothing. (Names a message.) (Field: a name.)
  • amount: a whole number = 1. How much it’s worth: the data sent with its Message, and how many of its Item. (Field: a number.)
  • item: text = null. An item it puts in the collector’s Inventory (one is added if it has none), e.g. “Key”, or its team’s items if it has none of its own (see Items): coins a hero collects for a strategy faction’s gold. Empty puts nothing there. (Names an item: this entity’s own, which other fields can name.) (Field: a name.)
  • price: text = null. What it costs to collect, e.g. “10 Coin”: a shop’s wares. It stays where it is until whatever touches it can pay, and is paid from the collector’s items (or its team’s, see Items) as it’s collected. Empty is free. (Items and how many of each, separated by commas, e.g. “150 Gold, 50 Wood”. The Inspector lists them a row each, the item picked from the project’s and the count set.) (Field: its own editor: Counts.)
  • sound: text = null. A sound played when it’s collected, e.g. “Sounds/coin.wav”. (A sound in Assets, e.g. “Sounds/hit.wav”.) (Field: a sound.)
  • heal: a number = 0. Hit points it gives back to whoever collects it: a heart, a medkit. One that only heals (with no Item) is left where it is while their health is full. (Field: a number.)
  • effect: text = null. A prefab spawned where it was, e.g. “Sparkle”: a burst of particles, a score popup. (Names a prefab.) (Field: a name.)
  • tintEffect: true or false = true. Gives the Effect’s particles this entity’s sprite color, so one sparkle suits every pickup. (Only used when effect is set.) (Field: on or off.)
  • spin: a number = 0. Degrees per second it turns while waiting to be collected. 0 keeps it still. (Field: a number.)

Not saved with the scene; scripts read them, and entity_get shows them as live while the game plays.

  • isCollected: true or false. True once it has been collected (it disappears at the end of that frame).

Scripts use it as Pickup: its methods, events and values that aren’t saved with the scene.