x

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"

How can I send data over network to only one client?

Here is the deal. We have an online game in UE4. Replicating stuff from client to server and from server to clients isn't that much of a problem BUT here is our use case: Each player has 1 character to control. Server calculates "visibility" of each character towards another player. So for example if S (Server player) is behind C1 (client one player) and C2 is seeing both of them, we want to send data to C1 only so that he hides S character on that machine only.

How do you send/replicate stuff to one client only?

Product Version: UE 4.21
Tags:
more ▼

asked Mar 15 '19 at 10:22 AM in C++ Programming

avatar image

Pablo1517
26 1 7 10

(comments are locked)
10|2000 characters needed characters left

2 answers: sort voted first

As Lafolie mentioned, I think that the best way to achieve what you want is by using RPC calls. Here is a simple setup to call a function only on a given client :

Inside your player controller class' header (make sure not to forget the _Implementation in the .cpp part) :

     UFUNCTION(Client, Reliable)
     void ClientFunction();

Then server-side, you call the function on a given controller :

     MyPlayerController->ClientFunction();

This RPC call will only be wired to the client owning the player controller.

Hope it helps!

Cheers.

more ▼

answered Mar 16 '19 at 04:49 PM

avatar image

Elou44
174 3 7 4

(comments are locked)
10|2000 characters needed characters left

Hi Pablo1517. the concept you are dealing with is known as Actor Relevancy. You can find details on how this works in the docs here. There is also another means of controlling relevancy but it is more catered towards games with a large replicated actor count (such as a multiplayer game with a large number of players like Fortnite or PUBG).

By default the engine employs a distance-based relevancy policy, which sounds similar to the solution you want to employ. It's not clear from your description what exactly you're trying to achieve; if using less bandwidth is your concern then you should probably have more faith in the engine, or you can adjust the update frequency - the replication is quite efficient for what it does (the default distance is quite large yet still performs well!). If the hiding is a mechanic in your game (such as fog of war) then you might consider using RPCs to handle this instead of net relevance.

more ▼

answered Mar 16 '19 at 09:14 AM

avatar image

Lafolie
26 1 1 1

(comments are locked)
10|2000 characters needed characters left
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