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"

Replicating a random int in multiplayer

Hello! I have a power up that i can spawn. This power up spawns with a random material, and light color. This is chosen with a random integer with the range of 0 ->4. This works 100% in single player, and server side. However the client seems to re do the random integer, and thus spawn with a different material, and light color after i set the variable to replicated.

How can i set this integer to be the same for both client, and server side?

alt text

Product Version: UE 4.10
capture 4.png (197.1 kB)
more ▼

asked Jan 30 '16 at 09:31 PM in Blueprint Scripting

avatar image

7 4 4 7

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

1 answer: sort voted first


You're doing the replication wrong. You want to set the variable to a repnotify, rather than replicated. Then next you want to set the random int on the server(not multicast).

Then go to functions and there you see a newly created function called OnRepSomething and in that variable do the part that comes behind the int set.

Reason why it doesn't work is because you're doing the random on all clients rather than the server. alt text

screenshot_50.png (390.0 kB)
more ▼

answered Jan 30 '16 at 09:49 PM

avatar image

591 18 24 43

avatar image psychoticpolice Jan 30 '16 at 10:09 PM

Thanks man, worked like a charm. I had a feeling it was being randomized across all clients, just new to the engine, and didn't know how to fix it.

(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