[2016.06.18-18.45.44:976][247]LogNetTraffic:Error: ReadContentBlockHeader: Stably named sub-object not found. Component: [16]BP_Sabre_C_0.[20]GAtStab_c_C_1, Actor: BP_Sabre_C_0
I’ve recently re-based my Weapon class from an Actor to an ActorComponent. Lot’s of reasons why, but I’m now having issues (see log entry above) with replication which is preventing players from joining each other. I’m using a similar system to the unreal ShooterGame example.
Here’s the code that spawns the weapon (Server-Side only). Obviously I want these to spawn, then replicate down the the Client. They will always be owned by the actor that uses them.
UBZGame_Weapon* NewWeapon = NewObject<UBZGame_Weapon>(GetOwner(), HardPoints*.DefaultWeapon);
NewWeapon->SetIsReplicated(true);
NewWeapon->SetNetAddressable();
ASSERTV(NewWeapon != nullptr, TEXT("Unable To Create New Weapon Component"));
NewWeapon->RegisterComponent();
AddWeapon(NewWeapon, i);
A couple of things… first I noticed that calling ‘SetIsReplicated’ on the component actually adds it to the Actors’ replication list, which seems fine (though, it does mean I can’t set bReplicates to true by default in UBZGame_Weapon, it seems?). I’m also not sure if I’m supposed to directly call ‘SetNetAddressable()’… or what it really does.
The spawning itself is done inside another UActorComponent, the ‘Game Object Component’, hence why I’m using ‘GetOwner()’ as the Outer for NewObject(). Unfortunately however, it seems as though the auto-naming for the object is causing this issue.
Just as background, I essentially spawn Weapon Objects when a powerup is collected, or when the owning pawn is initially spawned etc. Actors have a lot of overhead and a lot of junk that I don’t need for these classes, and that’s important in an FPS / RTS mix where I have hundreds of Actors, all with up to ten weapons each etc.