TeslasuitDocumentation
Plugins

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#

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:

FieldPurpose
BoneWeightThresholdValue in [0:1] controlling how many bordering vertices are pulled into each collider. Lower includes more.
AvatarSettingsThe TsAvatarSettings used to find bone transforms.
ChannelsThe TsHapticSimplifiedChannel assets to build, for example the bundled arm and chest channels.
HapticPlayerThe 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:

FieldPurpose
Max ImpulseImpulse that maps to full impact. With Max Impulse = 100, an impulse of 50 gives impact 0.5.
Min Collision Duration MsMinimum haptic duration while the objects stay in contact.
Haptic MaterialThe 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.