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"

The correct way to replicate a building


I am a bit puzzled and would just like some feedback on witch method is correct. my character can place a building and this replicates the placed building across the network. after executing on the server

now my question: if the building is already replicated what would be the best method for the following (both work).

Building one is a battery (collects power- has variable (currentpower and maxpower)) Building 2 is a generator it stores +1 power every second into the battery.

Method 1: no additional replication the generator is running the +1 power every event tick. and stores it successfully.

Method 2: generator calls an event on the battery to increase storage by +1 every second, this runs on the server and replicates to clients (using replicated variables (currentpower and maxpower)).

what would be considered the correct approach? as it feels like i am replicating twice: first when built and then on updates, but my understanding of networking is still a bit unclear hence the question

Thank you :)

Product Version: UE 4.11
more ▼

asked Jun 07 '16 at 03:32 PM in Blueprint Scripting

avatar image

25 1 1 5

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

1 answer: sort voted first

spawn a building on server, call multicast to spawn on clients.

add +1 power on a timer in both client and server machines, (No replication)

when power fills up or gets used, do that on the server, and multicast to clients. if power fills up on client, stop adding +1 to power, but don't trigger any "fully powered" events until the server version is filled.

so the server does all the important stuff, but the client adds their own power over time, just as a visual effect that estimates what is going on in the server. when an actor does this kind of client side estimation, it is known as a simulated proxy.

more ▼

answered Jun 07 '16 at 03:49 PM

avatar image

9.6k 320 205 450

avatar image ScRuFFnuF Jun 07 '16 at 04:58 PM

Thank you that gave me a lot more clarity,

just one more question if I may.

The timer would that be located on each generator ? and send a message to the battery ( I can have multiple generators to increase the amount). or should i rather have 1 timer on the battery that adds the accumulated amount every second ?

avatar image ScottSpadea Jun 07 '16 at 05:32 PM

1 timer on the battery, adding up all connected generator's charging rates, seems to be an efficient method to reduce function call overhead and simplify communication.

avatar image ScRuFFnuF Jun 07 '16 at 06:04 PM

I appreciate the push in the right direction :)

I have it set up as the timer executing the add or subtract every second and every building makes one call to change the value (runs on server )

basically i changed it to how you explained :) thanks

avatar image ScRuFFnuF Jun 07 '16 at 06:09 PM

although if I do not replicate the variable (current Power) it doesnt show on client

I have a authority check before changes and a replicate to updates

(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