Skip to main content
The Enemy class represents a hostile entity that roams the game world and can harm or interact with the ball. Scripts attached to an enemy receive it as self in hooks such as OnDeath and OnUpdate. Through the Enemy API you can read its position and orientation, toggle whether it responds to specific level hazards (via EnemyInteraction flags), and kill or disable it programmatically.

Properties

Identity

Transform

Data

Methods

enable / disable

Activate or deactivate the enemy. A disabled enemy is removed from play until re-enabled.

kill

Destroys the enemy immediately, triggering its death logic.

enableInteraction / disableInteraction

Toggle whether the enemy responds to a specific EnemyInteraction type.

setInteractionEnabled

A single-call alternative to enableInteraction/disableInteraction.

isInteractionEnabled

Returns true when the given interaction is currently active for this enemy.

Type-cast helpers

Use these to narrow a generic entity reference to a concrete type. Each throws an error if the cast is invalid.

EnemyInteraction Enum

The EnemyInteraction enum controls which level hazards and mechanics the enemy reacts to. Use it with the interaction methods above.

EnemyData

EnemyData is the mutable data representation used when building or modifying level data (e.g. in OnLevelLoad). It exposes template, scriptRef, scriptTag, scriptVars, properties, the read-only initialPosition (BlockLocation), and an interactions array (EnemyInteraction[]). The same four interaction helper methods — enableInteraction, disableInteraction, setInteractionEnabled, isInteractionEnabled — are available on EnemyData for use at design time. Call clear() to reset all fields.

Usage Example

The OnDeath hook fires when an enemy is killed. The example below checks whether the ball that killed the enemy has a shield, then disables all spike interactions on a second enemy:
You can also interact with enemies from a side script. The snippet below kills every enemy in the section when the ball rolls onto a specific trigger side: