Attach Actor to socket via C++

Not sure what the “LASERTAG_API” thing is for either, it starts to show up now when you make a class through the editor, its new to 4.3.

I think I’m getting closer to getting this put together. I didn’t spawn the weapon, that’s what I’m working on now, just trying to figure out SpawnActor, apparently I need a class of the weapon to pass into SpawnActor? All I have is a mesh, so Im assuming they mean blueprint of that mesh, and then I can pass that blueprint into SpawnActor as a class?

I have another question for you; in your AttachWeaponToPawn method, were is the weapon? I’m looking at the AttachRootComponentTo call and I don’t see an item being attached.

With this code:



 void ALaserTagCharacter::BeginPlay()
 {
     FActorSpawnParameters spawnParams;
     spawnParams.Owner = this;
 
     AMyWeapon* wep = GetWorld()->SpawnActor<AMyWeapon>(AMyWeapon::StaticClass(), spawnParams);
     if (wep)
     {
         wep->AttachWeaponToPawn(GetWorld()->GetFirstPlayerController()->GetPawn(), TEXT("HeroTPP"));
     }
 }
 

I’m able to see the MyWeapon class show up in the scene outliner when I run the game, but there is no weapon mesh. I think I may be using the AttachWeaponToPawn method incorrectly, or I misunderstood its intended purpose.