OnRep events without a replicated variable?

Hello, I am working with Unreal since few years but I am very new to multiplayer. So my question might sound silly or I may have misunderstood the concept. But I couldn’t find a similar question so here it goes.

I have an EnemySpawner class which is responsible from spawning enemies and placing them into the world. Enemies are replicated. This is basically a co-op shooter type of game.

To spawn an enemy on clients and server, I am currently using RPCs. But I’ve read that I should use RPCs for not so important things, such as audio cues, visual effects and so on. Not sure why this is the case since I can set it to Reliable (I assume all players login at the same time and there are no disconnects etc. for now).

So I decided to use OnRep events to spawn enemy in a reliable manner. But I don’t really need a variable for this. So far all the tutorials and lessons that I’ve seen ties an OnRep function to a variable using UFUNCTION(ReplicatedUsing = … ) format. I don’t really need a variable and I just need to call the function. How can I achieve this? Thanks.

When you spawn a Replicated Actor on the server it gets replicated to all the clients when the Actor is relevant to them so there is no need for any RPC when spawning something that is already set to Replicate.

It might be tempting to use reliable RPC’s but you can easily oversaturate a connection and end up disconnecting a client instead. Reliable RPC’s should only be used for infrequent game breaking events if missed and Replicated variables are also reliable but able to skip intermediate changes to avoid saturating the connections.

1 Like

Thank you for detailed explanation. I will try to work out from here.