Particle Component Not Visible To Clients

I’m calling “UGameplayStatics::SpawnEmitterAttached” to attach a particle system to the third person mesh of the ShooterGame player. However this particle effect is not visible to any of the clients in the game, only to the server.

The effect is a stun. When one player hit’s another, they are stunned for some time. During that time, they play the stun effect to everyone who can see them.

I’ve read this link (https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/Components/index.html) on replicating components but I haven’t had any success.

I also read that you need to enable replication on the component you are attaching to. This has not helped.

Here’s my code for the sake of completeness:

	//	Play our effect.
	//
	UParticleSystemComponent* effect = UGameplayStatics::SpawnEmitterAttached(
		StunEffectTemplate, Mesh, FName("b_Hips"),
		FVector(0), FRotator(90,-90,0));
	effect->SetOwnerNoSee(false);
	effect->SetOnlyOwnerSee(false);
	effect->SetIsReplicated(true);

Here is my constructor snippet:

	//	Enable replication for things we attach to this.
	//
	Mesh->SetIsReplicated(true);

Lol I feel like I’m overlooking something simple.

Any ideas?

I just tried to resolve this by placing the “UGameplayStatics::SpawnEmitterAttached” code within the authority and non-authority branches of my game logic (so it will run on client’s and the server).

It still doesn’t show the effect on clients.

Emitters are not replicated automatically.

If you want an emitter on all clients, you need to send a multicast event from your server and spawn the emitter on each client in the event handler.

Thanks for replying!

You are referring to this (https://docs.unrealengine.com/latest/INT/Gameplay/Networking/Replication/RPCs/index.html)?

This is new to me, but it makes complete sense. So I would basically declare:

UFUNCTION( NetMulticast );
void MulticastRPCFunction_PlayStunEffect();

And then define:

void MyClass::MulticastRPCFunction_PlayStunEffect()
{
	//	Logic to add my ParticleComponent.
}

And I would call this method on my authority logic, which would then call it on all connected clients?

I’m not near my code at the moment but I will try this out and reply with the results.

Right - except you need to define your function like this:

void MyClass::MulticastRPCFunction_PlayStunEffect_Implementation()
{

Oic.

So it goes like this:

UFUNCTION(NetMulticast, Unreliable)
    	void MulticastRPCFunction_PlayStunEffect();
    void MyClass::MulticastRPCFunction_PlayStunEffect_Implementation(){}

And when I want to call it, I can go to my authority logic and say:

//	Calls our RPC function on all clients.
//
MulticastRPCFunction_PlayStunEffect();

Yes give it a shot.

Your advice totally worked.

Thank you.