logo
By Lawrence

5 minutes

Flippers You Can Actually Hit With

The ball drains every time and there is nothing you can do about it. Two bats at the bottom of the playfield fix that — except that the first version of every flipper anyone writes has a maddening bug. Most swings work. Then, every so often, you swing hard at a ball and it passes clean through the bat as though the bat weren't there. No bounce, no sound, straight down the drain.

That is arithmetic, not a physics engine bug.

Add the two flippers

"Flipper_Left": {
  "tags": ["flipper", "flipper-left"],
  "components": {
    "MeshPrimitive": {
      "primitive": "box", "width": 2.4, "height": 0.4, "depth": 0.6,
      "position": [-3, 0.3, 15.1],
      "material": { "diffuseColor": [0.85, 0.85, 0.95], "emissiveColor": [0.1, 0.1, 0.2] }
    },
    "Shadow": { "castShadow": true, "receiveShadow": true },
    "Physics": {
      "shapeType": "box", "motionType": "kinematic",
      "mass": 1, "restitution": 0.4, "friction": 0.1, "autoCreate": false
    },
    "Flipper": {
      "restAngle": -0.555, "flipAngle": 0.5,
      "flipSpeed": 24, "returnSpeed": 12,
      "triggerKey": "ShiftLeft",
      "taperedGeometry": true, "length": 2.4, "direction": "left",
      "colliderInflate": { "y": 0.1, "z": 0.5 }
    },
    "PinballLayout": { "xCoeff": -0.1875, "zCoeff": 0.5, "zOffset": -1.5 }
  }
}

Flipper_Right is the mirror: xCoeff: 0.1875, restAngle: 0.555, flipAngle: -0.5, direction: "right", triggerKey: "ShiftRight", everything else identical. Both carry PinballLayout, so the bats travel with the table like the walls do — zCoeff: 0.5 with a zOffset: -1.5 parks them a fixed unit and a half above the bottom edge at any depth.

That restAngle: -0.555 matches Wall_BottomLeft, which has rotation: [0, -0.555, 0]. A resting flipper lies exactly parallel to the rail above it, so the two form one continuous funnel into the drain — until you lift the bat out of line.

Two settings in that block have no obvious business being there: autoCreate: false on the body, and colliderInflate on the flipper. Both serve the collider.

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