Hello, I have this blueprint to play a sound and visual effect when firing a weapon. The weapon is a child actor component of the character. The server player is correctly multicasting the effects so the client can see it, however, the replicating to server for a client causing the events is not working at all, I receive the string “replicating to server” but then nothing else happens. there is no string on the server to say it should be multicasting, so it looks as if the replication from the client to the server is not working, can anyone give any advice to fix this issue? All the input values are stated to replicate. Many thanks to anyone that can lend a hand
Hi, make sure that the client that calls this RunOnServer event owns this actor. Else it won’t be able to call RunOnServer events on this actor.
Also this only makes sense if there is only ever gonna be one client who will be calling RunOnServer events on this actor. If right now you want several clients to be able to do so, then change your logic so that you do all this through the server, so directly call the RunOnServer event where you handling the client input and then do the rest on the server, so you won’t need to call a RunOnServer event in this actor.
Child Actor Component Actors can’t replicate since the ChildActorComponent spawns the Actor on both Server and Client disregarding its replication settings.
You have to avoid using the Child Actor Component if your goal is to replicate the attached Actor.
If the server sets the Owner of the Rifle to the Character then the replication will work as soon as the ownership is updated.
Only the server can call multicast events. Generally logic and visuals should be separated. Here’s how I would do this. When a client tries to shoot, first check authority and make sure that the logic is handled on the server. Use a custom event that calls the same shoot function on the server if needed. Now that you are on the server, handle hit detection and damage logic here, after that call a multicast event. In that event, you can play the effects you want. So basically, the flow should be like this: Client tells server that I want to shoot > Server handles tracing and damage > Server tells everyone that “this player shot, everyone play shooting effects”.