logo

Babylon.js Market

By Lawrence

5 minutes

Every fight on this road has been settled with the front of your car. The oil and the gravel gave you a reason to pick a line, and the smoke gave you something to do about a pursuer, but there is still exactly one weapon in the game and you are sitting in it.

The fix isn't an inventory screen. It's a place on the route you choose to drive to.

A van on the right-hand shoulder

Append it to entities:

"Van": {
  "components": {
    "MeshPrimitive": {
      "primitive": "box",
      "width": 2.6,
      "height": 3,
      "depth": 7,
      "position": [6.8, 1.5, 110],
      "material": {
        "diffuseColor": [0.55, 0.5, 0.3],
        "emissiveColor": [0.08, 0.07, 0.03],
        "specularColor": [0.1, 0.1, 0.1]
      }
    },
    "Shadow": { "castShadow": true, "receiveShadow": false },
    "WeaponsVan": {
      "captureTag": "player",
      "hitRadius": 4,
      "holdSeconds": 0.9,
      "cooldownSeconds": 2.5,
      "exitForward": 11,
      "exitSide": -5.5,
      "weapons": ["machinegun", "missiles", "smokeScreen"],
      "ammo": 30,
      "uses": 0,
      "hideWhileHeld": true
    }
  }
}

At z: 110 the road's centreline has bent about 1.3 units right, so x: 6.8 parks the van on the shoulder with its back doors facing the traffic. It carries no tag of its own — it looks for captureTag, finds every entity tagged player, and never looks at itself.

Everything else on it is a clock.

Continue reading

Unlock the Full Course

Every lesson, the runnable examples, and the finished build — yours to keep.

$9one-time

Was this page helpful?

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

↑↓ NavigateEnter SelectEsc CloseCtrl+K Open Search