Hello, So for this question I will tell you about the behavior I want, the behavior I’m getting, and then post what I believe is the relevant code/ errors/ etc.
Desired Behavior:
Each character calls their ability. Abilities are networked and all clients see the result of the ability.
Actual Behavior:
Regardless of which owning client calls the PSAbility->OnUse() function, the behavior is always shown on the Nth client where N is the number of clients.
Errors that may be relevant
When played in editor with 4 clients while simulating a dedicated server I get the following error three times
AttachTo:'/Game/:PersistentLevel.PrimaryAugmentation.DefaultSceneRoot" cannot be attached to itself. Aborting.
The above error may be a big clue because we have 3 errors, and the ability only calls to one actor, but, it always effects the last client’s character that joins regardless of which client called the ability
Relevant Code
*code so we can select BP instances of PSAbility This is from PSCharacter *
/** Primary Augmentation */
UPROPERTY(EditDefaultsOnly, Category=Abilities)
TSubclassOf<class APSAbility> PrimAugClass; //Selected/Set in Blueprint instances
class APSAbility* PrimAug; // primary augmentation
Now for snippits of code that should give you an idea of how we are initializing & setting the above variables
void APSCharacter::PostInitializeComponents()
{
Super::PostInitializeComponents();
if (HasAuthority()) // I don't want actors to spawn on clients. They are purely functional/provide behaviors&effects
{
SpawnAbilities();
}
}
And now for the bit that spawns the subclass
// Spawning Functions //
void APSCharacter::SpawnAbilities()
{
UWorld World = GetWorld();
if (PrimAugClass != NULL)
{
FActorSpawnParameters SpawnParameters;
SpawnParameters.bAllowDuringConstructionScript = true;
SpawnParameters.bNoFail = true;
SpawnParameters.Instigator = Instigator;
SpawnParameters.Name = TEXT("PrimaryAugmentation");
SpawnParameters.Owner = this;
SpawnParameters.Template = NULL;
const FRotator SpawnRotation = GetControlRotation();
const FVector SpawnLocation = GetActorLocation();
PrimAug = World->SpawnActor<APSAbility>( PrimAugClass, SpawnParameters );
PrimAug->SetMyOwner(this);
}
Additional Information
When I check in debugger to check why this behavior occurs. The behavior we witness makes sense. This is regardless of which client calls OnUsePrimAug(), which executes on the server, the ability that executes always has the same ID, and reference to the same PSCharacter. But, as to WHY they all call the ability with the same ID, and MyOwner reference I have no clue.
Any thoughts, opinions, or ideas, that can help me solve this will be greatly appreciated.
Best Wishes,