Search in
Sort by:

Question Status:

Search help

  • Simple searches use one or more words. Separate the words with spaces (cat dog) to search cat,dog or both. Separate the words with plus signs (cat +dog) to search for items that may contain cat but must contain dog.
  • You can further refine your search on the search results page, where you can search by keywords, author, topic. These can be combined with each other. Examples
    • cat dog --matches anything with cat,dog or both
    • cat +dog --searches for cat +dog where dog is a mandatory term
    • cat -dog -- searches for cat excluding any result containing dog
    • [cats] —will restrict your search to results with topic named "cats"
    • [cats] [dogs] —will restrict your search to results with both topics, "cats", and "dogs"

Run On Server vs. Has Authority? (and more)

I'm creating a pretty simple pickup system and have a few questions about it. Shall we?

  1. I've heard that in multiplayer games we have to spawn actors through the server, but I honestly am not sure what it does mean. In my editor, for instance, I'm placing actors through the level screen and not programmatically. Is this acceptable? If not, do I really need to get the locations I want to place these items and manually spawn these Pickup Actors using a Blueprint (If so, which one?)?

  2. When a character picks an item up, I have to say to the server "hey, dude, player X picked item Y, do something.". But the thing is: do I need Switch Has Authority here? A simple Event Call with Run On Server wouldn't be enough, passing the player and the item that made the interaction?

  3. How Run On Server and Switch Has Authority are different? If I want to run something on the server, wouldn't be simply calling an Event replicating with Run On Server when I want the server to participate in the interaction?

Beforehand I must say I REALLY watched these videos and even though they're good, these certain things weren't clarified enough to me. In practice, these concepts just messed up in my mind.

Finally, pardon me if these questions are somehow duplicated.

Product Version: UE 4.18
more ▼

asked Feb 06 '18 at 02:10 PM in Using UE4

avatar image

53 3 11 14

avatar image ThompsonN13 Feb 06 '18 at 03:59 PM

to address your first question if you are adding things to your level by dragging them into the viewport in the editor that is a fine thing to do. the items you add this way will be in the game prior to runtime and thus will exist to every player. you only need to worry about using the server when your spawning things into the game at runtime. this is because if you let the individual clients spawn things into the game they could be cheating and in this instance the server and other clients wouldnt know it happened so replication would be a mess. for this reason and many others in multiplayer games its best to have a actions taken by the server.

avatar image chiefGui Feb 06 '18 at 05:14 PM

Thanks for the clarification, Thompson. The thing is: when dragging an actor into the level viewport, is it spawned by the server by default?

avatar image ThompsonN13 Feb 06 '18 at 05:33 PM

when dragging it into the viewport it is part of the base level so it isnt spawned at all in a sense, its built with the level so it exists to all players. replication only affects things that happen after the start of the game so if somethings in the level before the game starts everyone can see it, but if its spawned into the world after the beginning of the game only the one who spawned it can see it, until that person tells everyone else about it that is. thats where the server has an advantage as it can communicate with all clients, whereas the clients can only communicate with the server and not each other.

(comments are locked)
10|2000 characters needed characters left
Viewable by all users

1 answer: sort voted first
  1. As ThompsonN13 said, UE4 does not consider actors placed in the map (from the editor) to be "spawned". Spawning happens at runtime after the level is loaded. Actors placed in the map before runtime will work as if they were spawned on the server -- assuming replication was set up properly

  2. The RunOnServer functions will never run on clients so no, you do not need to check if it has authority

  3. RunOnServer and SwitchHasAuthority are different because RunOnServer is a flag you set on a function before runtime, while SwitchHasAuthority is a blueprint node that gets evaluated at runtime

There will be many times you will need SwitchHasAuthority, though. Most built-in functions don't assume they run on the server (i.e. BeginPlay, Tick, overlap events). Like on BeginPlay you may need to initialize a variable so you'd do a switch and the server would set and use the variable while the client would get and use the variable.

Hope that helps.

more ▼

answered Feb 06 '18 at 06:58 PM

avatar image

4.4k 32 79 42

avatar image chiefGui Feb 06 '18 at 07:37 PM

It really helps, @Jin_VE. Thank you very much for your response. It's clearer now. Just wanted these tutorials to dive into these details just like you did.

Again, thank you. :)

(comments are locked)
10|2000 characters needed characters left
Viewable by all users
Your answer
toggle preview:

Up to 5 attachments (including images) can be used with a maximum of 5.2 MB each and 5.2 MB total.

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question