Bone channels and collision
Windows · Unity 6000.0.44f1 · Plugin 2.6.0 · Requires Teslasuit Studio
This example turns physics collisions on a character into haptic feedback. It builds per body part colliders from simplified channels, attaches a collision handler to each, and uses a haptic material so that the strength of the feedback follows the collision impulse. The scene is TS/Examples/Scenes/Haptic/BoneChannels.unity.
What it demonstrates#
- Building colliders on a skinned character with
TsSimplifiedCollisionBuilder. - Converting collision events to haptics with
TsHapticCollisionHandler. - Driving impulse-based haptics from a moving object with
TsHapticImpulseMaterialObject.
Scene setup#
The scene has two sides: the character that receives haptics, and a physical object that strikes it.
On the character, the TsSimplifiedCollisionBuilder is added to the same GameObject as the SkinnedMeshRenderer. In the inspector it is given:
| Field | Purpose |
|---|---|
BoneWeightThreshold | Value in [0:1] controlling how many bordering vertices are pulled into each collider. Lower includes more. |
AvatarSettings | The TsAvatarSettings used to find bone transforms. |
Channels | The TsHapticSimplifiedChannel assets to build, for example the bundled arm and chest channels. |
HapticPlayer | The TsHapticPlayer that plays the resulting haptics. |
Checking Build in the editor generates one convex MeshCollider per channel, parented to the matching bone, each carrying a TsHapticCollisionHandler already wired to the channel and the player. After building, the character is ready to receive collision events and produce haptics.
The striking object has a Rigidbody, a Collider, and a TsHapticImpulseMaterialObject. Its fields:
| Field | Purpose |
|---|---|
Max Impulse | Impulse that maps to full impact. With Max Impulse = 100, an impulse of 50 gives impact 0.5. |
Min Collision Duration Ms | Minimum haptic duration while the objects stay in contact. |
Haptic Material | The TsHapticMaterialAsset that defines how the impact feels. |
The key API pattern#
You do not call these components directly; Unity's physics events drive them. When the striking object touches a collider built by the builder, it looks up the handler and feeds it a normalized impact.
private void OnCollisionStay(Collision collision)
{
var handler = collision.gameObject.GetComponent<TsHapticCollisionHandler>();
if (handler != null && handler.HapticPlayer.Device != null)
{
var playable = handler.HapticPlayer.PlayerHandle
.GetPlayable(m_hapticMaterial.Instance as IHapticAsset) as IHapticMaterialPlayable;
// impact = collision impulse / maxImpulse
handler.AddImpact(playable, collision.impulse.magnitude / maxImpulse, minCollisionDurationMs);
}
}A TsHapticMaterialAsset combines a haptic effect asset with a touch sequence asset, and is created from the menu Assets/Create/Teslasuit/Haptic/Haptic Material.
Safety. Collider building and impulse mapping can produce strong feedback on impact. Calibrate the suit, keep Max Impulse high enough that ordinary collisions map to modest impacts, and test with light contacts first.
What to read next#
TsSimplifiedCollisionBuilderreference: the build workflow and fields.- Haptics & EMS concept: materials, effects, and touch sequences.
