title: Atached Actor Mesh dont stick to Parent Actor
body: <p><strong>Context:</strong></p>
  
  <p>I'm creating some Actors (Shields) using C++ in ActorComponent (ShieldComponent) which is attached to Actor (Ship).
  When I move my Ship, Actors (Shields) stay in place on world (don't move with Ship).</p>
  
  <p><em>What can be important:</em> I don't call <code>CreateShieldActor</code> in Constructor, so I can't use <code>ConstructorHelpers::FObjectFinder</code> instead of <code>StaticLoadObject/LoadObject</code> to load Mesh/Material.</p>
  
  <p><strong>My C++ code for creation looks like this:</strong></p>
  
  <pre><code>AShieldPart* UShieldComponent::CreateShieldActor(AActor* Owner, FString MeshName)
  {
      //Create Shield Actor
      FVector Location = Owner-&gt;GetActorLocation();
      FRotator Rotator(0, 0, 0);
      FVector Scale(10, 10, 10);
      FActorSpawnParameters SpawnInfo;
      SpawnInfo.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AdjustIfPossibleButAlwaysSpawn;
      SpawnInfo.Owner = Owner;
  
      FTransform Transform(Rotator, Location, Scale);
      UClass * MeshClass = AShieldPart::StaticClass();
  
      AShieldPart* ShieldPart = GetWorld()-&gt;SpawnActor&lt;AShieldPart&gt;(MeshClass, Transform, SpawnInfo);
  
      //Attach Mesh to Shield Actor
      ShieldPart-&gt;AttachToActor(Owner, FAttachmentTransformRules(EAttachmentRule::KeepRelative, false));
  
      //Set Mesh for Shield
      ShieldPart-&gt;SetNewMesh(MeshName);
  
      //Set Material
      UMaterial* Material = Cast&lt;UMaterial&gt;(StaticLoadObject(UMaterial::StaticClass(), NULL, TEXT("/some/path")));
      ShieldPart-&gt;MeshComponent-&gt;SetMaterial(0, Material);
  
      return ShieldPart;
  }
  
  
  AShieldPart::AShieldPart()
  {
      // Set this actor to call Tick() every frame.  You can turn this off to improve performance if you don't need it.
      PrimaryActorTick.bCanEverTick = true;
  
      RootComponent = CreateDefaultSubobject&lt;USceneComponent&gt;(TEXT("RootComponent"));
      SetRootComponent(RootComponent);
  
      MeshComponent = CreateDefaultSubobject&lt;UStaticMeshComponent&gt;(TEXT("MeshComponent"));
      MeshComponent-&gt;SetupAttachment(RootComponent);
  }
  
  void AShieldPart::SetNewMesh(FString MeshName)
  {
      UStaticMesh* Mesh = Cast&lt;UStaticMesh&gt;(StaticLoadObject(UStaticMesh::StaticClass(), NULL, *MeshName));
      //UStaticMesh* Mesh = LoadObject&lt;UStaticMesh&gt;(nullptr, *MeshName);
      MeshComponent-&gt;SetStaticMesh(Mesh);
      MeshComponent-&gt;SetCollisionProfileName(TEXT("BlockAll"));
      MeshComponent-&gt;SetNotifyRigidBodyCollision(true);
      MeshComponent-&gt;SetSimulatePhysics(true);
      MeshComponent-&gt;SetEnableGravity(false);
  
      MeshComponent-&gt;RegisterComponent();
  }
  
  </code></pre>
  
  <p>That it would be more interesting, when I create that Actors (Shields) using BP all works fine...</p>
  
  <p><a href="https://i.stack.imgur.com/LpKUD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LpKUD.png" alt="enter image description here"></a></p>