Issue with NetMulticast

So in my gamemode .h file (CGameMode.h) I have this declaration:

UFUNCTION(NetMulticast, Reliable)
	void updatePlayerState();

Then in .cpp I have this:

void ACGameMode::updatePlayerState() {


Simple as can be however I get the following error when trying to compile:

Error EconomicallyViable.generated.cpp.obj : error LNK2005: "public: void __cdecl ACGameMode::updatePlayerState(void)" (?updatePlayerState@ACGameMode@@QEAAXXZ) already defined in CGameMode.cpp.obj

Apart from any coding errors that you might have (you have not posted the full source though) the GameMode does not support replication. It lives only on the server and so any attempt to replicate something to or from it will be to no avail.

Replication is based on the concept of owning a connection such as a PlayerController which is a connected client to your host etc. I would suggest to read the documentation about what and you can replicate your data and then design your system accordingly.

Thanks. I’ve been reading the documentation over and over it’s just a little light on examples and specifics. I did find where I was getting my error by looking at other people’s code. It appears I need to use my function like so:


adding in the suffix _Implementation but I still need to updatePlayerState();.

But your updatePlayerState method can not be called within the GameMode, nor will it be replicated. If it’s something that should get called on all clients you could consider variable replication within the GameState, this way you could hold a ‘State’ variable that gets updated on the server and will be replicated to all clients. RPCs are heavier than variable replication and in most cases variable replication is enough.

Thanks, I’m kind of trying different stuff but will be moving this to GameState per your advice. It’s mainly to setup some variables when the player first joins an online match. I read in the docs that having replicated variables also has the slight overhead of having the constantly check those variables for changes. Since these variables don’t change I thought perhaps calling a function once at the start would be a better way to go about things.

If you update only once a RPC is a good solution but if it turns out you are calling it far more often the bandwidth consumption is far worst then the overhead of a single variable.