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"),
Here is my constructor snippet:
// Enable replication for things we attach to this.
Lol I feel like I’m overlooking something simple.
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 );
And then define:
// 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:
So it goes like this:
And when I want to call it, I can go to my authority logic and say:
// Calls our RPC function on all clients.
Your advice totally worked.