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"

[Closed] RepNotify with additional information

Hi there,

This question is really asking for advice about how best structurally to tackle a problem we are having with RepNotify.

We have lots of Characters in the world. Each character has a CharacterSheet, which contains most importantly an integer array of stats, e.g. Agility, Strength, Armour, Health. The stat array is indexed by a StatType enum.

The Character Sheet has a function on it called SetStat(StatType stat, int32 newValue). We currently have the Stat int array set to RepNotify and the OnRep_Stats function calls an EventDispatcher called OnStatChanged which notifies the UI binds to so that it can update when a stat has changed.

This was working fine, however now we need more information. When the stat changes, I need the OnStatChanged Event to know what stat has changed, what the old value was and what the new value is. i.e. OnStatChanged( StatType Stat, int32 OldValue, int32 New Value). However, RepNotify only tells clients when a stat has changed, and doesn't know have this information.

Is there a nice way to do this? We have ideas, but none of them seem great. Any advice would be much appreciated.

Thanks, - Rich

Product Version: Not Selected
Tags:
more ▼

asked Mar 27 '16 at 02:42 PM in Using UE4

avatar image

Answers.Archive STAFF
1.8k 184 294 650

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

The question has been closed Mar 27 '16 at 02:43 PM by AndrewHurley for the following reason:

The question is answered, right answer was accepted


1 answer: sort voted first

Hi Richard,

We would like to support RepNotify parameters in blueprints at some point, but for now you'll have to use a workaround. In addition, there is currently a known issue with C++ RepNotify array parameters, which we also hope to fix.

The easiest workaround that comes to mind is to store your own "shadow" copy of the replicated array on the object. When the client receives the OnRep, it can compare the shadow copy to the current array to determine what changed and act on it, if necessary. Afterwards, it would store the current array into the shadow array. This is essentially what the engine does behind the scenes in order to know when to call RepNotifies.

more ▼

answered Mar 27 '16 at 02:42 PM

avatar image

Answers.Archive STAFF
1.8k 184 294 650

avatar image Answers.Archive STAFF Mar 27 '16 at 02:42 PM

Hey Richard,

If you are in C++ you can add a parameter to your OnRep function and that will automatically be the old value. I hope I understood your question correctly :) Please let me know if this didn't work.

Thanks, Osman

avatar image Answers.Archive STAFF Mar 27 '16 at 02:42 PM

Thanks for your quick reply and yes, you understand correctly. We do have access to C++ but this class is fully in Blueprints and we'd rather not switch it to code if possible but we will if we have to. Is there another way of doing this in blueprints?

Thanks - Rich

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

Follow this question

Once you sign in you will be able to subscribe for any updates here

Answers to this question