Replicated spawning issue from a clientside ui element

Hello,

I am an extreme novice at network programming and have a programmed single player ability system that I am adapting into a multiplayer game. I have a UI bar not unlike a mmo that the player can select to spawn an ability.

If I spawn the ability on the parent NPC class it spawns doubly on the player client and once on the other client. The only way that the game didn’t crash upon activating it was through multicast.

I moved the code to the GameState so I have eliminated all of the crashing! But it seems like no matter which replication settings I’ve set the spawn ability actor event to, I can only seem to get it to spawn on the caster’s client and not the other client.

The ability itself is a actor spawned into the game space. I feel like I am missing something fundamental here with networking, but I have been agonizing over this bug for months now in silence.

Attached are two screenshots, the first being the code one the GameState that spawns the ability actor and the second one from the UI element.


In the second screenshot from the Gamestate it looks like you didn’t mark the events as “Run on server”. You can do that by selecting the event and then on the right panel you can find the option. Check “reliable” too.
Then the description should change to

Eventname
Executes On Server

To learn more about multiplayer programming, read Cedric’s multiplayer network compendium, it’s really good:

the result is that nothing happens now that I click when playing from either client, or as listen server. the function isn’t called at all.

Is your ability a replicated actor? If the ability is something that spawn/die fast like a bullet. You might need a different setup.

1.Set up the 2 custom events to [Run on Server] and [Multicast].
2.Do as the first picture you shown should be fine, make sure to call the Run on Server one.
3.Server pass the variables to the Multicast function
4.Do spawn actor on the multicast function

Each client/server would have use the same variable to create the actor. Works for things like fireball/bullet/explosion where the server/client don’t need to have the same actor.