logo

Babylon.js Market

By Lawrence

5 minutes

Keep driving past the convoy and the highway runs on forever — that is what a treadmill does. Put water across it at z: 240 and the car has to become something else, or stop.

The river

Append it to entities:

"River": {
  "components": {
    "MeshPrimitive": {
      "primitive": "box",
      "width": 30,
      "height": 0.12,
      "depth": 160,
      "position": [4.3, 0.02, 320],
      "material": {
        "diffuseColor": [0.07, 0.2, 0.3],
        "specularColor": [0.5, 0.55, 0.6],
        "alpha": 0.85
      }
    }
  }
}

Thirty wide and 160 long, centred at z: 320, so the near bank is at 240 and the far one at 400. Its x: 4.3 is not a round number by accident — that is exactly where the road's centreline sits at z: 320, since 5 · sin(2π · 320 / 240) is 4.33. The river crosses the road square on.

Then the vehicle's half, into Player.components, above Health:

"BoatMode": {
  "waterMaxSpeed": 20,
  "waterGrip": 0.25,
  "waterAcceleration": 7,
  "waterBraking": 3,
  "waterSteerRate": 2,
  "waterDrag": 1.4,
  "draft": 0.25,
  "bobAmplitude": 0.12,
  "bobFrequency": 0.7,
  "settleRate": 4,
  "hullWidth": 2.4,
  "hullHeight": 0.6,
  "hullLength": 4.8,
  "hullColor": [0.8, 0.76, 0.68],
  "hideVehicleMesh": true
}

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