Attach a Prop to the Player's Hand in Banter
Banter provides an attachment component and a UserData.Attach() method for placing GameObjects on supported player body locations. This example builds a small prop and attaches it to the right hand.
Create the prop GameObject and geometry, then choose the component-based or user-method attachment API.
- Create a lightweight prop with a clear name and transform.
- Add its visual geometry and material.
- Attach it with
BS.AttachmentType.RightHand.
Create the Prop
const handProp = new BS.GameObject({
name: "RightHandProp",
localPosition: new BS.Vector3(0, 0, 0),
localEulerAngles: new BS.Vector3(0, 0, 0),
localScale: new BS.Vector3(1, 1, 1)
});
handProp.AddComponent(
new BS.BanterBox({
width: 0.12,
height: 0.12,
depth: 0.35
})
);
Add a Material
handProp.AddComponent(
new BS.BanterMaterial({
shaderName: "Unlit/Diffuse",
texture: "",
color: new BS.Vector4(0.2, 0.8, 1, 1),
side: BS.MaterialSide.Front,
generateMipMaps: false
})
);
Attach with BanterAttachedObject
handProp.AddComponent(
new BS.BanterAttachedObject({
attachmentType:
BS.AttachmentType.RightHand
})
);
The component attaches its GameObject to the selected player body part.
Attach through UserData
The official user API also provides:
scene.localUser.Attach(
handProp,
BS.AttachmentType.RightHand
);
Use the current scene's localUser when the prop belongs to the local player.
Supported Attachment Types
The official reference lists:
BS.AttachmentType.HeadBS.AttachmentType.LeftHandBS.AttachmentType.RightHandBS.AttachmentType.LeftFootBS.AttachmentType.RightFootBS.AttachmentType.ChestBS.AttachmentType.Back
Use the enum value rather than typing the body location as a string.
Build a Chest Badge Instead
Change only the attachment type:
handProp.AddComponent(
new BS.BanterAttachedObject({
attachmentType:
BS.AttachmentType.Chest
})
);
Rename the GameObject to match its role when reusing the example for another body location.
Common Questions
Why does my Banter prop not attach to the right hand?
Pass the documented enum value BS.AttachmentType.RightHand to BanterAttachedObject or UserData.Attach().
Which Banter body attachment locations are documented?
The official API lists the head, left and right hands, left and right feet, chest, and back.
Official References
Related Navigation
- Attach Banter Objects to Users
- Banter GameObjects and Hierarchies
- Banter Physics and Grabbable Objects
- Banter VR Documentation