Replication Question - Execute on both client and server


How do I get something to execute on both the client and server?

For example if I want to set the Character Movement’s “Orient Rotation to Movement” depending on whether I set the event to “Execute on Server” or “Execute on Owning Client”, it will only do one or the other.

What is the correct way of having it execute on both? I thought Multicast would do this but it only does it on the current client… perhaps because the client can’t execute it.

This is my work around but it stems from not knowing what I’m doing…

Thanks for any help!

I’m not sure how correct this is, but it seems to work for clients and the server. I’m using it to play an animation and set a bool.
On the client it triggers the top custom event that runs on the server. If it’s the server, it skips that node and just goes for the function that calls the lower custom event that is set to multicast.

Thanks Bohrium,

Yeah that makes more sense than what I did. I hope someone can respond with a certain answer on if we are doing it properly… beats having to redo a whole game :wink:

Ah Borhium,

After trying it, I found a huge issue with an event that is called on tick, gets spammed with ‘Too many calls to RPC…’ if you use multicast. Back to my way… until someone tells me better.

I’m fairly sure that you never want to have replicated events running on tick anyway. I was (sort of) guilty of this in one place on my own project as well, but I redesigned the system so that it used a replicated event to open a gate, which allowed each client to set the rotation of a character with it’s own ticks. That way I only have to replicate it once and the clients themselves can do the heavy lifting. But again I very much doubt that there’s any situation where you have to send events from the server to clients at a rate like that.

it will really depend on exactly what your trying to replicate, For example when i spawn items from my inventory into the world for it to replicate i have my drop function replicated to run on server -> switch has authority -> and both auth and remote have to be pluged into my next function which is get drop location-> spawnActor

Doesn’t make much sense to me. For example, if I make an event that is run on server and reliable with a switch has authority → remote → print string “hello”, it will never be printed because the event runs on the server…

So how does your has authority -> remote execute that function?

I guess Bohrium already provided you with a working example but to clear up something you may have misunderstood about Multicast functions: Multicast is what you want to use if you want something to be executed on all clients, the thing is for this to happen it has to be executed on the server because clients by design don’t have the authority to tell other clients what to do. So if you want the client to trigger something to happen to all clients, you have to do a Server RPC, which in turn executes the Multicast RPC, which is exactly what Bohrium is doing.

There was never any confusion about that, one of us are confusing something that’s been said :slight_smile:

This isn’t associated with the issue presented in the thread, and I’m also not sure what you’re trying to do :slight_smile: The variables aren’t even being replicated in the image you posted and there’s no calls to the server or client happening which is what this thread is dealing with.

I’m trying to figure out the appropriate method for having functions execute on both the server and the client, variables aren’t involved.

Wow… I didn’t click OK on the Photoshop dialog, so it didn’t overwrite the PNG I always upload, here is the correct photo:

Hah been there…

Can you show what Crouch Server and Crouch Client are doing? Presumably the exact same thing?

Yes, the two events are hooked up to the same crouching code.