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"

Use of delegates in Blueprint and Network

I made a new delegate, like this.

 DECLARE_DYNAMIC_MULTICAST_DELEGATE_ThreeParams(FGameStateTimeOfDayChanged, uint32, Houer, uint32, Minute, uint32, Sec);

And then i added it to my class like this.

 UPROPERTY(BlueprintAssignable, Category = "Time Of Day")
     FGameStateTimeOfDayChanged OnTimeUpdated;

Then in the method i have in my Game State class to update the time, i want to Broadcast / "Send" the event. (The method where i use ::Broadcast(,,) is only ever called on the server.)

     OnTimeUpdated.Broadcast(CurrentHouer, CurrentMinute, CurrentSeconds);

But the problem is that i can only see the delegate fire on the server, but should they not also fire on the clients as they also have the GameState and its Broadcasted from the server?

I know for a UFUNCTION() i can use NetMulticast to have the method execute on all clients. Is this not the same for MULTICAST Delegates?

Product Version: Not Selected
Tags:
more ▼

asked Aug 11 '14 at 01:25 PM in C++ Programming

avatar image

WCode
508 43 44 73

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

2 answers: sort voted first

Delegates are not replicated.

Executing delegate from server, on clients it's bit tricky, need some forethought and invovles writing quite a bit of supporting code.

  1. All data you will try to send trough delegate, will need to be replicated. DOREPLIFETIME or other macro, depending on how you want to replicate it.

  2. Then you will need to use NetMulticast or Client RPC call, trough function. Depends if you want to execute delegate on all clients or only on owner. On your RPC function you simply Broadcast delegate.

  3. Another option is using RepNotify, Depending on your needs it might be enough. I would experiment with both and see which will be better for you. RepNotify tends to be more lightwieght for networking, but it is also less reliable, than RPC.

    UPROPERTY(Replicated) Type CurrentHouer;

    UFUNCTION(NetMulticast, Relibale) /// or Unreliable void NetMulticast() { OnTimeUpdated.Broadcast(CurrentHouer, CurrentMinute, CurrentSeconds); }

more ▼

answered Aug 12 '14 at 09:48 AM

avatar image

iniside
1.6k 105 98 185

avatar image WCode Aug 12 '14 at 10:27 PM

Thank you that clears that up. Cheers!

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

I think delegate it's kind of like an event, and you still need to tell the event to run on client, server or netmulticast, i don't know exactly multicast use for though.

more ▼

answered Aug 12 '14 at 08:53 AM

avatar image

Duncan Dam
3.1k 121 50 164

avatar image WCode Aug 13 '14 at 11:01 PM

You are correct, what i ended up doing is Broadcast the event a second time when OnRep_CurrentSeconds is called. That way i did not have to send the data twice to get actors with no GameState to be able to pick it up.

(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