# Capsules and Mesh Transforms

{% hint style="info" %}
The information in this page only applies to versions **before v40**. If you're on v40 or later, this has been replaced with the [Replicated Capsule Component](/platform-documentation/creation/unreal-development/features-and-tutorials/replicated-capsule-component.md) and [Morpheus Animated Skeleton Component](/platform-documentation/creation/unreal-development/features-and-tutorials/morpheus-animated-skeleton-component.md).
{% endhint %}

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 `GetSkeletalMeshLocalTransform`on 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 `SetCalculateSkeletalMeshTranslationFromCapsule`or 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](/platform-documentation/creation/unreal-development/getting-started/differences-in-unreal-development-workflow/msquared-character-configuration.md)). 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.

<figure><img src="/files/mv6K8V40hU3hFQIMvtxN" alt=""><figcaption><p>Viewing capsule colliders with <code>show COLLISION</code> shows the resizes capsules for the different avatars.</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.otherside.xyz/platform-documentation/creation/unreal-development/features-and-tutorials/avatars/capsules.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
