# Problem replicating a scene component.

**URL:** <https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986>\
**Category:** Programming & Scripting\
**Tags:** unreal-engine, Multiplayer, question\
**Created:** [October 21, 2023, 5:04pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986 "2023-10-21T17:04:42Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 5:04pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/1 "2023-10-21T17:04:42Z")

</div>

I’m trying to replicate the position of a scene component.  
But i don’t have the same transform values on the server and client side.  
Give me a hand please. What am I doing wrong?

The actor is replicated.

 ![repl](https://d3kjluh73b9h9o.cloudfront.net/original/4X/6/d/a/6da95d26ef366983187c435fa93fb2f3b164c3b8.png)

The component is replicated

![Component](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/1/5/4151361f358abbf99c9f152d2034eaca6966908d.png)

This is the component tree of the actor

![Tree](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/d/b/4db022b93fe466d2d742af69347ad27d37ebc1b6.png)

This is how I am printing the values

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/c/0/8c0603fd990e1714b4f0bd9850786f846c9b0dd5.png)

This is a log capture

 ![Log](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/6/5/c65e3a825f86a7129b9f172aa9a1c5e9ade8f80d.png)

And this is a video

If you need more information just ask me

Thank you so much!!

* * *

UPDATE

* * *

I was tracing the code. i think the problem start when the weapon is attached.  
This code is exectuted on server.

```auto

const FAttachmentTransformRules AttachmentRules =	FAttachmentTransformRules
	(
			EAttachmentRule::SnapToTarget,
			EAttachmentRule::SnapToTarget,
			EAttachmentRule::KeepWorld,
			true
	);
	
	AttachToComponent(Parent, AttachmentRules, SocketName);

```

However after this the transform is not igual in both sides.  
¿Any idea?

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 6:59pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/2 "2023-10-21T18:59:25Z")

</div>

It looks like you are controlling the movement from the client’s input, so it will only update on the client and not the server. If you do it from the perspective of the server, does it update correctly?

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 7:03pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/3 "2023-10-21T19:03:36Z")

</div>

Let me try it. Thank you so much!!

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 7:19pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/5 "2023-10-21T19:19:33Z")

</div>

> [@SteveRambo](#):
>
> If you do it from the perspective of the server, does it update correctly?

Ohh, i sorry now understand it.  
Yes, the server does it update correctly.  
the server has not problem

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 7:23pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/6 "2023-10-21T19:23:04Z")

</div>

Is the weapon being attached to the player pawn?

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 7:27pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/7 "2023-10-21T19:27:49Z")

</div>

Yes.  
-First the weapon is spawned in the world  
-Then the player pick up the weapon and attach it  
-And the probem start here (Only for the client)

if you want i’ll upload other video to show you all this.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 7:35pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/8 "2023-10-21T19:35:08Z")

</div>

like this:

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 7:37pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/9 "2023-10-21T19:37:25Z")

</div>

No need, the issue isn’t the weapon, it is actually the player pawn. If the movement is replicated, the location will update when walking around. In the pawn settings, are you using controller rotation yaw or pitch? Generally, you would just use yaw, then manually set the control rotation pitch to feed into an aim offset (for animation BP). This will make it so the entire pawn doesn’t rotate its pitch, just the mesh. For testing purposes, if you enable use controller pitch as well (assuming yaw is already enabled), this should correct the issue.

Edit: you should use a listen server with 1 server player and 1 client player. Then using the client, walk in view of the server player and move/look around. This should show you what is being replicated.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 7:53pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/10 "2023-10-21T19:53:12Z")

</div>

I’m using this cofiguration:

I have a replicated control rotation to get move the spine bone of the pawn.

 ![control rotarion](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/4/0/4408842cccc11f5f46ddac4a27b0c0868ab49019.png)

And this configuration in the character class.

![control rotarion2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/e/9/3/e93b14e4b487cd52790cc90f569a5365cb9dfc11.png)

The case is this configuration work for me for months.  
The weapon worked too.  
I change the character a few days ago and the problems started.

I going to show you other video… replication work well (I think)

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 8:00pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/11 "2023-10-21T20:00:03Z")

</div>

Look this:

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 8:10pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/12 "2023-10-21T20:10:34Z")

</div>

Can you show what the player component hierarchy looks like? And what component are you attaching the weapon to?

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 8:20pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/13 "2023-10-21T20:20:49Z")

</div>

Yes, of course… i going to do it now.

I just to edit two videos more becouse i want to show you this.  
This is very very rare.

When the server no see the client, the client can not shoot (the tranform is not replicated well)…

When the server see the client, the client can shoot well (the weapon works)

Very confused…

I goint to get this…

> [@SteveRambo](#):
>
> component hierarchy

wait a moment please.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 8:33pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/14 "2023-10-21T20:33:23Z")

</div>

> [@SteveRambo](#):
>
> Can you show what the player component hierarchy looks like? And what component are you attaching the weapon to?

The SceneComponents:

 ![1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/d/c/0dc2525ba5a9da0584b5cc41c20af5f760d23eb2.png)

I attaching the weapon to a socket in the skeleton.

 ![2](https://d3kjluh73b9h9o.cloudfront.net/original/4X/8/d/4/8d4633a0aab16648e3b86d92142b93821df3bc9c.jpeg)

I just realize… i posted a wrong video in my las post (The second video) i fixed it…  
What do you think about it?

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 8:47pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/15 "2023-10-21T20:47:55Z")

</div>

When attaching, try setting the location to snap to target, but for rotation make it keep relative. See if it helps.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 8:55pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/16 "2023-10-21T20:55:28Z")

</div>

like this?

```auto
const FTransform WeaponSocket = AttachableStaticMesh->GetSocketTransform(FComponentSocketName::RightHand, RTS_Component);
AttachableStaticMesh->SetRelativeTransform(WeaponSocket.Inverse());

```

this no help… i already was using it

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 9:08pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/17 "2023-10-21T21:08:17Z")

</div>

or do you mean like this?

```auto
	const FAttachmentTransformRules AttachmentRules =	FAttachmentTransformRules
	(
			EAttachmentRule::SnapToTarget,
			EAttachmentRule::KeepRelative,
			EAttachmentRule::KeepWorld,
			true
	);	
	AttachToComponent(Parent, AttachmentRules, SocketName);

```

it does not work too.

i try the character control rotation too. More or less works… but the projectile is not spawned exactly in the weapon cannon.

```auto
void AWeaponAttachable::SpawnProjectile_Implementation(APawn* TheInstigator, TSubclassOf<AActor> Projectile)
{
	if (!IsValid(SpawnLocation))
	{
		message::Error("AWeaponAttachable::SpawnProjectile -> SpawnLocation is NULL");
		return;		
	}

	const FVector Location = SpawnLocation->GetComponentLocation( );
	//const FRotator Rotation = SpawnLocation->GetComponentRotation( );
	const FVector ForwardVector = SpawnLocation->GetForwardVector();
	const FRotator Rotation = TheInstigator->GetControlRotation();
	
	
	const FVector VtSpawnLocation = FVector
	(
		Location.X + ForwardVector.X * 1.0f, // 50.0f,
		Location.Y + ForwardVector.Y *1.0f, // 50.0f,
		Location.Z + ForwardVector.Z * 0.0f
	);	
	
	UWorld* World = GetWorld();
	if (!IsValid(World))
	{
		message::Error("AWeaponAttachable::SpawnProjectile -> World is NULL");
		return;		
	}	

	FActorSpawnParameters SpawnParameters = FActorSpawnParameters();
	SpawnParameters.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
	SpawnParameters.TransformScaleMethod = ESpawnActorScaleMethod::MultiplyWithRoot;
	SpawnParameters.Owner = this;
	SpawnParameters.Instigator = TheInstigator;
	
	World->SpawnActor(Projectile, &VtSpawnLocation, &Rotation, SpawnParameters);
}

```

---

<div class="post-metadata">

**Author:** ![SteveRambo](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@SteveRambo](https://forums.unrealengine.com/u/SteveRambo)\
**Post date:** [October 21, 2023, 9:20pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/18 "2023-10-21T21:20:19Z")

</div>

You have the GripPoint socket, but where do you use it? I only see RightHand

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 9:37pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/19 "2023-10-21T21:37:25Z")

</div>

Good question!!

Basicly it is the variable “socketName” in here…

> [@Ivan3z](#):
>
> `AttachToComponent(Parent, AttachmentRules, SocketName);`

i’m using poliformismis and virtual functions to handle several attachable objects.

`virtual FName GetParentSocketName() override;`

So the weapons objects use this:

```auto

FName AWeaponAttachable::GetParentSocketName()
{
	return FComponentSocketName::Weapon;
}

```

i have defined the socket names in a struct.  
`inline static const FName Weapon	= "GripPoint";`

Basicly if the pawn is overlapping with a attachable object and it is a weapon then is attached in the hand…

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 9:45pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/20 "2023-10-21T21:45:52Z")

</div>

> [@Ivan3z](#):
>
> `FComponentSocketName::RightHand`

You got a point… this skeleton has not “FComponentSocketName::RightHand” Socket… i goint to add it to check if it help.

---

<div class="post-metadata">

**Author:** ![Ivan3z](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ivan3z](https://forums.unrealengine.com/u/Ivan3z)\
**Post date:** [October 21, 2023, 10:16pm UTC](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986/21 "2023-10-21T22:16:37Z")

</div>

Ok, it was not help…  
Did you see the video where the cannon position works when the server can see the client?  
So rare…  
What do you think about it?

[Next page](https://forums.unrealengine.com/t/problem-replicating-a-scene-component/1339986.md?page=2)
