# Use Relative Character Replication when Attached \[Resolved\]

**URL:** <https://forums.unrealengine.com/t/use-relative-character-replication-when-attached-resolved/1913738>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, question\
**Created:** [June 23, 2024, 2:53pm UTC](https://forums.unrealengine.com/t/use-relative-character-replication-when-attached-resolved/1913738 "2024-06-23T14:53:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Loux\_xavier](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loux_xavier/32/1201519_2.png) [@Loux\_xavier](https://forums.unrealengine.com/u/Loux_xavier)\
**Post date:** [June 23, 2024, 2:53pm UTC](https://forums.unrealengine.com/t/use-relative-character-replication-when-attached-resolved/1913738/1 "2024-06-23T14:53:49Z")

</div>

Hello,  
I need the opinion of people who know how UCharacter and UCharacterMovement replication works.

In my game, I need a character to be attached with a relative position of 0 to a component of another replicated actor. The component deliberately uses a different relative position between the client and the server.

The problem is that the replication of the character forces it to move and ignores the relative position of its parent. _[See image 1]_

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/f/6/9f69e5b3cda7ca65cfe031f51ec202929a6343a3.jpeg)

I would like to force the replication of the character to be based on its relative position when attached or when I define it (With a bool or something) as it does by default when it is on a platform. _[See image 2]_

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/9/8/8/9883f26a6b6e18cdebdde439b89c9e21f1d74448.jpeg)

For the moment the best way I have found is to force the location I want in an override of `UCharacterMovementComponent::OnMovementUpdated`. I’m not sure it a good method.

Thanks!

---

<div class="post-metadata">

**Author:** ![Loux\_xavier](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/loux_xavier/32/1201519_2.png) [@Loux\_xavier](https://forums.unrealengine.com/u/Loux_xavier)\
**Post date:** [May 1, 2025, 6:48pm UTC](https://forums.unrealengine.com/t/use-relative-character-replication-when-attached-resolved/1913738/2 "2025-05-01T18:48:31Z")

</div>

Hello!  
I was able to fix the issue using based movement and a custom movement mode.

You should know that both the server and the client use the **relative transform** of `BasedMovement.MovementBase` for character replication. If `MovementBase` is `NULL`, the **absolute transform** is used instead.

`MovementBase` is set automatically by movement modes like the walking mode when the character lands on the ground, or cleared (set to `NULL`) when the character is falling.

So I created a new custom movement mode to set the base component when the player is attached, using an override of `UTagCharacterMovementComponent::PhysCustom`:

```C++
void UTagCharacterMovementComponent::PhysCustom(float deltaTime, int32 Iterations)
{
	if (CustomMovementMode == CUSTOM_MOVEMENT_MODE_STUCKTOZONE)
	{
		PhysStuckToZone(deltaTime, Iterations);
	}

	Super::PhysCustom(deltaTime, Iterations);
}

void UTagCharacterMovementComponent::PhysStuckToZone(float deltaTime, int32 Iterations)
{
	// Code with SetBase()
}

```

Now, the client will replicate the character’s position based on the attached component instead of the world transform. The tricky part is that based movement is generally used **without attachment**.

- Without attachment: if my base component moves 50, the character also moves 50 cm.

- With attachment: if the base moves 50 cm, the character moves 50 cm from the attachment **plus** another 50 cm from the movement base logic so it moves 100 cm in total.

But thanks it possible to simply cancel based movement updates during this mode by overriding `UTagCharacterMovementComponent::UpdateBasedMovement`:

```C++
void UTagCharacterMovementComponent::UpdateBasedMovement(float DeltaSeconds)
{
	if (MovementMode == MOVE_Custom && CustomMovementMode == CUSTOM_MOVEMENT_MODE_STUCKTOZONE)
	{
		// Disable base movement update when using the stuck zone
		return;
	}
	Super::UpdateBasedMovement(DeltaSeconds);
}

```

 ![image](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/0/8/1081d1b26e849e267d95e416271ca0b4739e334e.jpeg)

I’m not sure if it’s the best solution, but it’s definitely much cleaner than recalculate and forcing the client’s position in `UCharacterMovementComponent::OnMovementUpdated`.

Hope this helps someone else!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 31, 2025, 6:49pm UTC](https://forums.unrealengine.com/t/use-relative-character-replication-when-attached-resolved/1913738/3 "2025-05-31T18:49:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
