Projectile class represents a single in-flight projectile in RollingQuest. You create projectiles by calling LevelSection:createProjectile() with either a ProjectileRequest object or an inline property table. Once created, a Projectile lets you read and write its physics parameters, control its collision behaviour, and hook into fire, explode, and update events. The companion ProjectileRequest class is the recommended way to configure a projectile before launch.
Projectile
Properties
Identity
| Property | Type | Read-only | Description |
|---|---|---|---|
skin | string | ✅ | Visual skin identifier of the projectile. |
isActive | boolean | ✅ | true while the projectile is in flight. |
section | string | ✅ | ID of the section whose projectile pool owns this instance. |
isHoming | boolean | ✅ | true when homingStrength > 0. |
Transform
| Property | Type | Read-only | Description |
|---|---|---|---|
position | Vector3 | ❌ | Current world-space position. |
rotation | Quaternion | ❌ | Current world-space rotation. |
forward | Vector3 | ✅ | Normalised forward direction derived from rotation. |
velocity | Vector3 | ✅ | Current velocity vector. |
angularVelocity | number | ✅ | Current angular velocity (read-only derived value). |
Movement
| Property | Type | Read-only | Description |
|---|---|---|---|
lifetime | number | ❌ | Remaining lifetime in seconds before the projectile auto-expires. |
speed | number | ❌ | Linear speed along the forward axis. |
acceleration | number | ❌ | Rate of change of speed per second. |
angularSpeed | number | ❌ | Rotational speed around the local axis. |
angularAcceleration | number | ❌ | Rate of change of angularSpeed per second. |
angularLocalAxisRotation | Vector3 | ❌ | Local axis around which angular rotation is applied. |
homingStrength | number | ❌ | Strength of the steering force toward the nearest ball. |
maxHomingRange | number | ❌ | Maximum distance at which homing tracking activates. |
Collision Behaviour
| Property | Type | Read-only | Description |
|---|---|---|---|
explodeOnCollideWithBlocks | boolean | ❌ | Detonate when hitting a block side. |
explodeOnCollideWithItems | boolean | ❌ | Detonate when hitting an item. |
explodeOnCollideWithEnemies | boolean | ❌ | Detonate when hitting an enemy. |
explodeOnCollideWithBalls | boolean | ❌ | Detonate when hitting a ball. |
explodeOnCollideWithDecorations | boolean | ❌ | Detonate when hitting a decoration. |
Methods
fire
Launch the projectile. Six overloads give you control over the starting position, rotation, and speed:explode
Detonate the projectile immediately:Event callbacks
You can attach Lua functions to three lifecycle events after creation:ProjectileRequest
ProjectileRequest is a configuration object you build before calling LevelSection:createProjectile(). Using it keeps your creation code readable and gives you access to all properties in one place.
Static Constructor
Three overloads create a new request:Properties
AllProjectileRequest properties are read/write.
| Property | Type | Description |
|---|---|---|
skin | string | Visual skin identifier. |
origin | Vector3 | World-space spawn position. |
rotation | Quaternion | Initial rotation at spawn. |
tag | string | Optional tag for lookup or categorisation. |
power | integer | Damage power of the projectile. |
lifetime | number | Duration in seconds before auto-expiry. |
speed | number | Initial linear speed. |
acceleration | number | Rate of speed change per second. |
homingStrength | number | Steering strength toward the nearest ball. |
maxHomingRange | number | Maximum homing detection range. |
autoFire | boolean | When true the projectile fires immediately on creation. |
explodeOnCollideWithBlocks | boolean | Detonate on block collision. |
explodeOnCollideWithItems | boolean | Detonate on item collision. |
explodeOnCollideWithEnemies | boolean | Detonate on enemy collision. |
explodeOnCollideWithBalls | boolean | Detonate on ball collision. |
explodeOnCollideWithDecorations | boolean | Detonate on decoration collision. |
explodeOnCollideWithProjectiles | boolean | Detonate on projectile collision. |
onFire | fun(projectile: Projectile): void | Callback invoked when the projectile fires. |
onExplode | fun(projectile: Projectile): void | Callback invoked when the projectile explodes. |
onUpdate | fun(projectile: Projectile, deltaTime: number): void | Callback invoked every update tick. |
Creating and Firing a Projectile
You create a projectile through theLevelSection object. The example below fires a homing projectile from a side each time the ball rolls onto it: