Capsules and Mesh Transforms

M2UP's handling of the capsule component and mesh transforms when using MML avatars.

M2UP provides tooling and automatic handling of capsule components and the mesh transforms on avatars to help deal with MML avatars of different sizes, and how these changes can be applied to avatars in the crowd.

Skeletal Mesh Transform

Setting the transform

Render target actors (non-crowd) have a parent capsule component with a skeletal mesh inside. You should generally not set the transform of your skeletal mesh directly, since this won't apply to the avatar when they move in and out of the crowd.

Instead, use SetSkeletalMeshLocalTransform on the render target's MorpheusActor. This will apply the transform for the render target while it's an actor or in the crowd. You can use GetSkeletalMeshLocalTransformon a MorpheusActor to retrieve this transform on a render target even when it's in the crowd.

This mesh transform data is not replicated.

Automatic handling of translation

By default, M2UP automatically sets the translation of the MeshLocalTransform property whenever the capsule size of the MorpheusActor changes. The translation will be set to place the render target in the centre of the capsule, ensuring the avatar sits squarely on the floor.

You can configure this behaviour on a per-actor basis with SetCalculateSkeletalMeshTranslationFromCapsuleor globally (including at runtime) with the LiveConfig game.Capsule.CalculateSkeletalMeshTranslationFromCapsule.

Capsule Size

Setting the capsule size

Render target actors (non-crowd) have a parent capsule component. You should generally not set the size of your capsule component directly, since this won't apply when they move in and out of the crowd.

Instead, the render target's MorpheusActor has a replicated CapsuleData property. You can set on the authoritative characters only with SetCapsuleData and retrieve the value on all characters with GetCapsuleData, using the UJM_CharacterCapsule helper functions to use the FCapsuleData struct.

This property is replicated in the background, so all users will see the change to the capsule size.

OnCapsuleChanged is a delegate that's fired when the capsule component changes size as a result of locally changing the size on the auth player or receiving a changed size over the network.

Automatic capsule resizing

Each character loads in with the capsule component specified in the defaults for the pawn class that is spawned (specified in your character configuration). By default, when a player loads in a new MML avatar, the capsule component will resize to include the bounds of that avatar.

UpdateCapsuleSizeFromAvatar is the function that's called when characters load in a new avatar, and you can call manually.

If you'd rather keep the capsules all the same size or handle this logic yourself, you can disable this with the game.Capsule.MatchCustomMesh LiveConfig.

Last updated