Log inGet started
Package

Slime.component

Newest version

README.md

Slime

One slime: its faceted lime body, its hop, its chase, its touch and its death.

Attach to a synced root entity together with Vitals ({ maxHp = Rules.SLIME_MAX_HP, hp = Rules.SLIME_MAX_HP }, player = false). game/slimes/spawner.luau does that for every slime the arena has; nothing needs to place one by hand.

What it does

  • Builds the body under the root on every peer — dome, skirt, deeper core, dot eyes and smile — from game/slimes/body.luau and the meshes in game/slimes/domeMesh.luau. Only the root replicates, so the look is free.
  • On the peer that owns the root: hops (SLIME_HOP_PERIOD, SLIME_HOP_HEIGHT) with a squash-and-stretch cycle, seeks the nearest living player within SLIME_CHASE_RANGE at SLIME_SPEED, and touches for SLIME_DAMAGE no more often than SLIME_TOUCH_COOLDOWN, through game.combat.vitals.
  • On every peer: flashes white when hurt, and on death plays the splat and the slime_die cue. The owner despawns the root.

Health, damage, death, the 10 XP a kill pays and everything about leveling are game.combat.vitals' business. This component only listens.

Fields

FieldMeaning
zonewhich of Rules.SLIME_ZONES (1-based) it was born at — the spawner's bookkeeping
squashthe vertical squash the owner is playing, so other peers draw the same hop

Notes

  • Slimes.all() / onSpawn / onDespawn (game/slimes/registry.luau) is how other slices find slimes; this registers on awake and unregisters on onDestroy and on death.
  • Its awake calls require("game.slimes.spawner").ensure(), so a slime that exists at all keeps the zones filling.