I’m building a co-op game and I’m trying to ensure that there are some tasks in the game that are achievable together. One of those tasks is lighting a fire. However, I’m having problems replicating the fire to the clients.
When a character goes to use an item. The particle effect doesn’t spawn on his screen or any of the other clients.
However, it is spawning on what I’m assuming is the server since it’s the main window in the Unreal Engine editor.
UFUNCTION(reliable, server, WithValidation)
void UseItem();
void AShooterCharacter::UseItem_Implementation()
{
if (Role < ROLE_Authority)
{
return;
}
//Code removed that gets the overlapping actors and loops through them
AUsableItem* const TestPickup = Cast<AUsableItem>(CollectedActors[iCollected]);
if (TestPickup && !TestPickup->isActive)
{
TestPickup->isActive = true;
TestPickup->UseTheItem();
}
}
}
class SHOOTERGAME_API AHiddenFire : public AUsableItem
.
.
.
public:
virtual void UseTheItem() override;
UPROPERTY(EditDefaultsOnly, Category = "Particle System")
UParticleSystem* FireSpawnFX;
void AHiddenFire::UseTheItem()
{
//This code also does not work. Validated its not just particle effects.
//FVector NewLocation = this->GetActorLocation() + FVector(0, 0, 300.0f);
//this->SetActorLocation(NewLocation);
UGameplayStatics::SpawnEmitterAtLocation(this, FireSpawnFX, GetActorLocation(), GetActorRotation());
}
}
I have also tried multicast. I set the UseItem to Netmulticast and then removed the if (Role < ROLE_Authority) code from the UseItem_Implementation and it worked on just the client that called it. If I left the if (Role < ROLE_Authority) in there, it was never called at all
and spawned on no clients.
Any help would be GREATLY appreciated. Even pointing me to a particular location in an example project would be helpful. Thank you for your time.