logo
Bullet

shooter

Bullet

1
Unlock

Install with the CLI:

bjs download Bullet

Bullet

Drives pooled projectile entities — flight, lifetime, and enemy collision.

What it does

Processes every live bullet entity (MeshPrimitive + Bullet): each frame it advances the bullet along its direction, decrements its lifetime, and tests it against live enemies. It expires a bullet on lifetime, on leaving the arena bounds, or when its travel segment crosses a bullet-blocking Obstacle wall (segment test, so fast shots can't tunnel). On an enemy hit it emits bullet.hit (for observers like SFX/hit-flashes, carrying the shot direction) then routes damage through HealthSystem via health.damage. Bullets are pooled — an expired or hitting bullet is released with world.removeEntity, which parks it back in the pool rather than destroying it.

Use it in a scene

A scene is just data — a list of entities, each with its components. At startup the SceneLoader turns this JSON into a live world; edit the file and reload to rebuild it.

Fastest path

bjs download scene Bullet

Pulls this exact scene into your project and runs it — no copy-paste. Add --all to grab the components and assets it needs too.

Or build it from scratch with the bjs CLI:

  1. 1Scaffold a project
    npm create @babylonjsmarket/arcade@latest my-game

    World, renderer, and dev server — ready to run.

  2. 2Install dependencies
    cd my-game && npm install
  3. 3Add Bullet
    bjs download Bullet

    Copies its source into src/ so the scene resolves.

    First time? Run bjs login once.

  4. 4Paste the scene into src/scenes/arcade-room.ts and run
    npm run dev

    SceneLoader builds the world from the JSON; reload to rebuild.

JSON
{
  "Projectile": {
    "tags": ["bullet"],
    "components": {
      "MeshPrimitive": {
        "primitive": "sphere", "diameter": 0.55, "position": [0, 0.8, 0],
        "material": { "diffuseColor": [1.0, 0.95, 0.35], "emissiveColor": [0.6, 0.55, 0.1] }
      },
      "Bullet": {
        "direction": [0, 0, 1], "speed": 18, "lifetime": 1.2, "damage": 1, "radius": 0.3,
        "arenaHalfWidth": 19.5, "arenaHalfDepth": 19.5
      }
    }
  }
}

Props

  • direction ([x,y,z], default [1, 0, 0]) — unit travel direction (XZ used).
  • speed (number, default 18) — flight speed in units/sec.
  • lifetime (number, default 1.2) — seconds before the bullet expires.
  • damage (number, default 1) — damage dealt on hit.
  • radius (number, default 0.3) — collision radius.
  • arenaHalfWidth / arenaHalfDepth (number, default 0) — out-of-bounds expiry; 0 = unbounded.

Events

  • emits bullet.hit (with entityId, damage, position, and dirX/dirZ) and health.damage on an enemy hit. bullet.hit fires before health.damage so TwinStickEnemySystem can read the shot direction when the hit kills synchronously.

Dependencies

MeshPrimitive — the bullet mesh this system flies. Health — receives health.damage so the hit actually subtracts HP. Obstacle — full-height walls that stop bullets (low cover lets them through).

Notes

In a real game bullets are handed out by a Pool blueprint, not authored individually — this component is the per-bullet behavior the pool's template carries. A bullet is skipped on its first frame after being acquired ("newborn") so it doesn't fight MeshPrimitiveSystem over its muzzle position. Only enemies that are active and not tagged dying can be hit, so corpses can't be re-hit / double-scored.

More like this

Health
MeshPrimitive
Obstacle
ShipDamageFX
TwinStickEnemy
AiPilot
Animation
ArcCamera
Asteroid
CameraFollow
ContactDamage
DirectionalLight
EnemySpawner
EnvironmentTexture
FreighterCar
FreighterChain
FreighterHead
GameConfig
HemisphericLight
Jump
KeyboardInput
KeyboardMover
Lifetime
LineOfSight
MachineGun
Mesh
Missile
MissileLauncher
MissionDirector
MoneyField
MouseInput
Movement
ObstacleField
OilBlob
Parts
Physics
PlayerInput
PlayerWalkAnimator
RespawnTimer
RoundReset
Score
Shadow
ShipLoadout
ShooterCamera
SkeletonAnimator
SmokeScreen
SpaceShooterBullet
SpaceShooterHealth
SpaceShooterScore
TwinStickShooter
WaveDirector
Waypoint
WaypointTrack
WeaponsVan

Was this page helpful?

We read every note — tell us what's working and what isn't.

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search