# Spawned Actor not attached until I click on it in World Outline

**URL:** <https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371>\
**Category:** Blueprint\
**Tags:** spawn, attach-to-component, world-outliner, unreal-engine, question\
**Created:** [December 3, 2020, 3:54pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371 "2020-12-03T15:54:59Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![CMDRRithwald](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CMDRRithwald](https://forums.unrealengine.com/u/CMDRRithwald)\
**Post date:** [December 3, 2020, 3:54pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371/1 "2020-12-03T15:54:59Z")

</div>

Hi All,

New to UE4 and I’m having an issue with spawning an actor and attaching it to my pawn.

I have a **TankPawn** , and when the game loads, I spawn a **Turret** , and attach it to a socket on the **TankPawn’s** StaticMesh.

```
void APlayerVehicle::SetTurret() {
	if (TurretClass)
	{
		FName SocketName = TEXT("TurretSocket");
		Turret = GetWorld()->SpawnActor<ATurretBase>(TurretClass);
		Turret->AttachToComponent(BaseMesh, FAttachmentTransformRules::KeepRelativeTransform, SocketName);
		Turret->SetOwner(GetOwner());
	}
}

```

I see the **Turret** , and its nested under the BaseMesh of my **TankPawn**.

![323808-outliner.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/3/0/a/30a0efd999b1e53864ec640918f50d5f9d41ac26.png)

When I move the **TankPawn** though my **Turret** stays behind.

![323809-detatch.png](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/1/c/01c6540062e9262c765436ff1fe73c591291a367.png)

However If I start the game and then click on the **Turret** in the **World Outliner** and then try to move, the **Turret** stays on my **TankPawn** , and rotates as I’d expect

Any idea of what I’m doing wrong?

---

<div class="post-metadata">

**Author:** ![Aherys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aherys/32/1194650_2.png) [@Aherys](https://forums.unrealengine.com/u/Aherys)\
**Post date:** [December 3, 2020, 5:10pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371/2 "2020-12-03T17:10:35Z")

</div>

Do you did it in multiplayer ?

---

<div class="post-metadata">

**Author:** ![CMDRRithwald](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CMDRRithwald](https://forums.unrealengine.com/u/CMDRRithwald)\
**Post date:** [December 3, 2020, 5:19pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371/3 "2020-12-03T17:19:29Z")

</div>

Just working on a single player implementation currently.

---

<div class="post-metadata">

**Author:** ![Aherys](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/aherys/32/1194650_2.png) [@Aherys](https://forums.unrealengine.com/u/Aherys)\
**Post date:** [December 3, 2020, 6:40pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371/4 "2020-12-03T18:40:31Z")

</div>

According to you’r answer,  
this look like ownership issue.

Try in blueprint to display the current owner (to see from server and client point of view).  
When you give ownership to something, you should give it from the server.

---

<div class="post-metadata">

**Author:** ![CMDRRithwald](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@CMDRRithwald](https://forums.unrealengine.com/u/CMDRRithwald)\
**Post date:** [December 3, 2020, 7:45pm UTC](https://forums.unrealengine.com/t/spawned-actor-not-attached-until-i-click-on-it-in-world-outline/475371/5 "2020-12-03T19:45:48Z")

</div>

Figured out my issue here. The **StaticMesh** that I was trying to connect to was in the parent class.  
By using **Super::BaseMesh** instead of **BaseMesh** it seemed to solve all the problems I was having.

Thanks **\_Aherys** for your responses, it helped.

```
    void APlayerVehicle::SetTurret() {
    	if (TurretClass)
    	{
    		FName SocketName = TEXT("TurretSocket");
    		Turret = GetWorld()->SpawnActor<ATurretBase>(TurretClass);
    		Turret->AttachToComponent(Super::BaseMesh, FAttachmentTransformRules::KeepRelativeTransform, SocketName);
    		Turret->SetOwner(GetOwner());
    	}
    }
```
