-1

I'm currently working on a multiplayer game, in which two teams (one red and one blue) fight against each other. The thing is that the server will sometimes have to some data to a specific team and not the other. I was wondering if it was possible to "filter" the multicast to prevent the server to send data to everyone ? Or to send the data to a specific list of clients ? I've been searching for a moment on several forums, and I haven't found anything interesting for the moment ^^

Thanks a lot !

aqwerty
  • 61
  • 8
  • Why do you want to do this out of interest, Surely you don't want clients to end up with unsynced data from the server? – George Jan 11 '20 at 21:39
  • I wanted to hide some actors from each other (some players from blue team aren't supposed to see some actors from red team for exemple). I finally achieved what I wanted to do by overriding the method 'IsNetRelevantFor' , with more infos here : https://docs.unrealengine.com/en-US/API/Runtime/Engine/GameFramework/AActor/IsNetRelevantFor/index.html – aqwerty Jan 21 '20 at 10:04

2 Answers2

1

The way that a UDP broadcast works is that a network IP and a mask is provided; machines where the ip's and mask match will get the message.

Since there's only one mask; it's designed to say what level of the network that the message should be broadcast to; but not to specific machines.

The usual way to get around this is to give each message a "topic" and then filter by topic; but still broadcast all the data to all machines.

For your specific example - you might have 3 topics. "RedData" "BlueData" "CommonData".

UKMonkey
  • 6,941
  • 3
  • 21
  • 30
  • I was thinking about doing it this way... It just bothers me that I'll have to send the data to anyone no matter what :/ But thanks anyway, at least it should work ! – aqwerty Jan 10 '20 at 10:50
  • The alternative would be to not broadcast - but the cost of this is that you end up having to send the same message multiple times - but to different clients each time. – UKMonkey Jan 10 '20 at 10:52
  • I see, not really optimized... I'll try to use the "topic" method, thanks a lot ! – aqwerty Jan 10 '20 at 11:12
  • A multicast in Unreal is not a UDP broadcast or UDP multicast afaik. – Rotem Jan 10 '20 at 18:35
1

You can use a Client RPC instead of a Multicast one, call it on the corresponding PlayerController and it will only be sent to any specific client(s).

Bas in het Veld
  • 1,271
  • 10
  • 17