Build a Synchronized Pickup in Banter

A Banter pickup can combine geometry, a matching collider, rigidbody physics, the VR grab component, and BanterSyncedObject. The synchronized-object component enables network synchronization for the GameObject.

Pickup Component Stack

Create one GameObject and add its visible shape, material, collider, rigidbody, grab behaviour, and synchronization component.

  1. Create and position the pickup GameObject.
  2. Add geometry, a matching collider, and BanterRigidbody.
  3. Add BanterGrababble, BanterSyncedObject, and event listeners.

Create the Pickup Object

const pickup = new BS.GameObject({
  name: "SyncedPickup",
  localPosition: new BS.Vector3(0, 1.25, 2)
});

pickup.AddComponent(
  new BS.BanterBox({
    width: 0.3,
    height: 0.3,
    depth: 0.3,
    widthSegments: 1,
    heightSegments: 1,
    depthSegments: 1
  })
);

Add a Material

pickup.AddComponent(
  new BS.BanterMaterial({
    shaderName: "Unlit/Diffuse",
    texture: "",
    color: new BS.Vector4(0.2, 0.8, 1, 1),
    side: BS.MaterialSide.Front,
    generateMipMaps: false
  })
);

BanterMaterial accepts a shader name, texture URL, RGBA colour, material side, and mip-map setting.

Add the Collider and Rigidbody

Match the collider dimensions to the box:

pickup.AddComponent(
  new BS.BoxCollider({
    isTrigger: false,
    center: new BS.Vector3(0, 0, 0),
    size: new BS.Vector3(0.3, 0.3, 0.3)
  })
);

pickup.AddComponent(
  new BS.BanterRigidbody({
    mass: 1,
    drag: 0,
    angularDrag: 0.05,
    useGravity: true,
    isKinematic: false,
    collisionDetectionMode:
      BS.CollisionDetectionMode.Continuous
  })
);

The rigidbody component provides the physics simulation used by the object.

Enable VR Grabbing

The documented API name is BanterGrababble:

pickup.AddComponent(
  new BS.BanterGrababble({
    grabType: BS.BanterGrabType.Default,
    grabRadius: 0.01,
    gunTriggerSensitivity: 0.5,
    gunTriggerFireRate: 0.1,
    gunTriggerAutoFire: false
  })
);

The same component also exposes per-hand input-blocking options when a held object needs custom controller behaviour.

Enable Network Synchronization

pickup.AddComponent(
  new BS.BanterSyncedObject()
);

The official reference describes BanterSyncedObject as enabling network synchronization for the object.

React to Grab and Drop

GameObjects emit grab and drop events:

pickup.On("grab", (event) => {
  console.log("Grab point:", event.detail.point);
  console.log("Hand:", event.detail.side);
});

pickup.On("drop", (event) => {
  console.log("Released by:", event.detail.side);
});

The grab event supplies the grab point and hand side. The drop event supplies the hand side.

Apply a Force

Keep the rigidbody reference when the object also needs scripted forces:

const body = pickup.GetComponent(
  BS.CT.BanterRigidbody
);

body.AddForce(
  new BS.Vector3(0, 3, 0),
  BS.ForceMode.Impulse
);

BanterRigidbody supports force, relative force, torque, explosion force, movement, rotation, sleep, and wake methods.

Common Questions

Why does my Banter pickup fall through other objects?

Confirm that the pickup has both a non-trigger collider and a non-kinematic rigidbody, and check that the collider size matches the visible geometry.

Why does my grab event not identify the hand?

Read event.detail.side from the GameObject's grab or drop event. The value uses the documented hand-side enum.

Official References

Related Navigation