Make a USE pickup in blueprint for multiplayer

So I took the blueprint pickup_parent from the content example as a starting place to create pickups (ie: give ammo , health , shield etc etc) next question would be how do I set them to work properly in multiplayer form?
I assume there must be some replication involved and such as just having a use key works fine single player wise but I am not sure what I really need to do to make it function in multiplayer so that it would give the right ammo, weapon or health to the proper player.

Hi Emile,

A simple model for something like a health pack pickup could look like this:

  • On client, player presses use, call ServerPickupObject(TheObject).
  • On server, ServerPickupObject verifies that it’s ok, updates the player’s health, and calls ClientPickupObject.
  • On client, ClientPickupObject does the cosmetic picking up (animation, audio, effects, etc). Could also do this immediately on client without waiting for server verification, which would reduce latency but could result in seeing pickup cosmetics when it really failed.
  • Player’s updated health replicates to the client via normal variable replication.

Good luck!

Jeff

Sorry but you lost me there. Is this blueprintable? ( I think I made a new word)
I can create everything upto the use key to pickup the object. but after that I am lost and your answer put me deeper into the woods than I thought I was :slight_smile:
is it possible to tell me what nodes I would need to link up. Would it help to put up a picture of the current blueprint maybe?

Yeah, I haven’t done it myself but this should all be available to do in blueprints.

To add a little more detail to my example above, you’ll need

  • a “server” replicated function in your PlayerController called ServerPickupObject. Call this when you hit “use”.
  • a “client” replicated function in your PlayerContoller called ClientPickupObject. Call this from ServerPickupObject and it will execute on the client who owns that PlayerController.
  • Player’s health stored somewhere, probably on his Character, and marked to replicate. When you change this on the server, it will automatically broadcast the new value to all the clients.

Jeff

So this will require C++ coding . I was hoping there was a way to do this all from within blueprints.

Everything should be doable in blueprints. You can make Server or Client RPCs by making custom events and editing the replication settings of the event nodes (the node that implements the custom event, not the node that calls the custom event).