Component:SkinnedMeshPositioner
More actions

The SkinnedMeshPositioner component drives a slot's transform so it stays locked to a specific triangle on a SkinnedMeshRenderer.
Normally you can attach things by parenting them to bones, which works okay. But for parts of the skinned mesh that are weighted to multiple bones and/or are affected by blendshapes, this will cause the object to "drift/slide" relative to the mesh. This component fixes that by computing the transform from the actual skinned mesh transform![1]
Fields
| Name | Type | Description |
|---|---|---|
persistent
|
Bool | Determines whether or not this item will be saved to the server. |
UpdateOrder
|
Int | Controls the order in which this component is updated. |
Enabled
|
Bool | Controls whether or not this component is enabled. Some components stop their functionality when this field is disabled, but some don't. |
Skin
|
SkinnedMeshRenderer | The skinned mesh renderer to attach this object to |
TriangleIndex
|
Int | The index of the triangle in the mesh to attach this object to |
BarycentricCoordinate
|
Float3 | How close the attachment point should be to each vertex of the triangle (barycentric coordinate system). |
LocalPosition
|
Float3 | An offset to apply to the position of the object |
LocalRotation
|
FloatQ | An offset to apply to the rotation of the object |
LocalScale
|
Float3 | A multiplier to apply to the scale of the object |
PositionDrive
|
field drive of Float3 | The position field of the slot to be driven with the position of the triangle in the SkinnedMeshRenderer |
RotationDrive
|
field drive of FloatQ | The rotation field of the slot to be driven with the rotation of the triangle in the SkinnedMeshRenderer |
ScaleDrive
|
field drive of Float3 | The scale field of the slot to be driven with the scale of the SkinnedMeshRenderer |
Sync Delegates
| Method Name | Method type and Arguments. | Is the method hidden? | Description |
|---|---|---|---|
ComputeParameters:ButtonEventHandler
|
ButtonEventHandler | ✓ | Calculates parameters to position the slot at its current position, rotation & scale, relative to the nearest triangle on the specified SkinnedMeshRenderer. This can be used to retarget this component to a new nearby SkinnedMeshRenderer Via a Protoflux MethodProxy |
Usage
To use this component, you should position a slot so that it is placed where you would like it to be anchored on the SkinnedMeshRenderer, attach this component to that slot, fill in the Skin field with a reference to the SkinnedMeshRenderer and select the Compute Parameters button in the Inspector. Once pressed, Resonite will fill in the TriangleIndex field with the index of the nearest triangle on the SkinnedMeshRenderer to that slot, fill in the BarycentricCoordinate, LocalPosition, LocalRotation & LocalScale fields with the values to keep the slot positioned where it was, relative to the selected triangle, and set the PositionDrive, RotationDrive & ScaleDrive fields to references to the respective slot fields.
To reset the component in case you want to transfer an object to a different point on your Avatar or to a different Avatar, simply first break the position and rotation drives then move it and if needed update the Skin slot with the new SkinnedMeshRenderer. If you update the Skin reference before breaking the drives your object will suddenly disappear as it will position itself relative to the TriangleIndex on the new Mesh using the data of your previous setup. This problem is similar to reparenting a Slot without preserving global position.
Demo
Overview and basic usage by Frooxius