Item and Container Logic

"Item" covers everything that is not a player or an enemy: weapons, pickups, breakable containers, projectiles, debris, and scenery objects. Set Entity Type to Item and the game treats the entity as an object rather than a character.

Items can be spawned from levels, from animation events, from containers, from projectiles, and from scripts.

What Items Are Used For

  • Pickups — food, money, extra lives.
  • Weapons — knives, pipes, swords, thrown weapons.
  • Breakable containers.
  • Projectiles and spawned effects.
  • Scenery and helper objects.

Most of the character-oriented settings in Logic Settings are irrelevant to an item. The ones that matter are the body box, the projectile fields, and the animation logic.

Projectiles

An item becomes a projectile in one of two places:

On the item itself — the Damage and Hit Pause projectile fields in Logic Settings, plus Hit Sound, Hit Sound Mod and Hit Channel.

On the spawning event — a Spawn Item event can mark the spawned item as a projectile with isProjectile, and then supply its own damage, hitPause, hitSoundName, hitSoundPack and hitSoundChannel, along with velocity, lifetime and positionOffset.

The event route is the flexible one: the same item can be spawned as a weak fast projectile by one move and a heavy slow one by another. Lifetime is in game frames, and 0 means the projectile persists until something destroys it — a common cause of projectiles that never disappear.

If a projectile needs movement more complex than a constant velocity, give its active animation a Lua script and let the spawn event handle only creation.

Behaviour Modes for Items

Items use behaviour modes on a different numbering scheme from players and enemies. In saved data, item mode values are even numbers starting at 0x02 for the first controller.

Use the editor's mode picker rather than typing numbers. Guessing a mode value is the usual reason a spawned item vanishes, freezes, ignores collision, or immediately switches to the wrong animation.

See Behaviour Modes.

Testing

An item has more states than a character, and each is a chance to get it wrong. For a weapon, walk through the whole life cycle:

  • Lying on the ground.
  • Picked up by a player, and by an enemy.
  • Swung, and connecting.
  • Thrown, in flight.
  • Hitting a wall.
  • Falling and landing.
  • Being destroyed or expiring.

Containers need the same treatment: intact, being hit, breaking, and whatever they spawn on breaking.

Related pages: The Inspector, Body and Hit Boxes, Logic Events, Logic Event Examples, Behaviour Modes, Audio Events, Spawns.