Build a Spring-Connected Platform in Banter

SpringJoint creates an elastic connection between physics objects. A two-body setup needs an anchor rigidbody and a platform rigidbody, with the joint's connectedBody set to the anchor rigidbody ID.

Spring Platform Workflow

Create the kinematic anchor first, keep its rigidbody reference, and connect a dynamic platform with SpringJoint.

  1. Create the anchor and store its rigidbody.
  2. Create the platform with geometry, collider, and dynamic rigidbody.
  3. Add SpringJoint with connectedBody: anchorBody.id.

Create the Anchor

const anchor = new BS.GameObject({
  name: "SpringAnchor",
  localPosition: new BS.Vector3(0, 4, 4)
});

const anchorBody = anchor.AddComponent(
  new BS.BanterRigidbody({
    useGravity: false,
    isKinematic: true
  })
);

The stored anchorBody reference supplies the connected rigidbody ID.

Create the Platform

const platform = new BS.GameObject({
  name: "SpringPlatform",
  localPosition: new BS.Vector3(0, 2, 4)
});

platform.AddComponent(
  new BS.BanterBox({
    width: 2,
    height: 0.25,
    depth: 2
  })
);

platform.AddComponent(
  new BS.BoxCollider({
    isTrigger: false,
    center: new BS.Vector3(0, 0, 0),
    size: new BS.Vector3(2, 0.25, 2)
  })
);

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

Add the Spring Joint

platform.AddComponent(
  new BS.SpringJoint({
    anchor: new BS.Vector3(0, 0, 0),
    connectedAnchor: new BS.Vector3(0, 0, 0),
    autoConfigureConnectedAnchor: true,
    spring: 10,
    damper: 0,
    minDistance: 0,
    maxDistance: 1,
    tolerance: 0.025,
    breakForce: Infinity,
    breakTorque: Infinity,
    enableCollision: false,
    connectedBody: anchorBody.id
  })
);

connectedBody uses the rigidbody ID of the other GameObject.

Understand the Spring Settings

The official component defines:

  • spring as spring force
  • damper as damping
  • minDistance and maxDistance
  • tolerance
  • breakForce and breakTorque
  • enableCollision
  • connectedBody

Adjust one physics value at a time and observe the resulting motion.

Add a Platform Material

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

Common Questions

Why is my Banter spring not connected to the anchor?

Store the anchor's rigidbody reference and pass anchorBody.id to the spring joint's connectedBody setting.

Which Banter SpringJoint setting reduces oscillation?

The official reference defines damper as damping. Adjust it alongside spring force and distance settings for the intended motion.

Official References

Related Navigation