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 do I force replication of property, even if value doesn't changed ?

How do I force replication on property ?

I want to replicate property, with each replication tick, regardless, of whether that property was changed or not. It's fairly simple struct with one float and one vector. And I need it to be always replicated, to upadte some cosmetic stuff on client.

Right now, client is completely desynced, because updates do not arrive, when there is no changed to property (and there won't be always changed in property, but there should be always updates on UI).

Product Version: Not Selected
Tags:
more ▼

asked Jul 23 '14 at 10:04 AM in C++ Programming

avatar image

iniside
1.6k 105 98 185

avatar image AnxGotta Jul 23 '14 at 11:42 AM

I'm having a hard time understanding the sense in this. If no values are changing how is the replication of the same value going to "update some cosmetic stuff"? Are you replicating using a function on the clients and your cosmetic updating code is in there?

avatar image iniside Jul 23 '14 at 11:45 AM

The only thing I replicate are Damage value and Location. And if you shoot non moving actor with constant damage, then value never change ;). But you still want to show this damage on Client.

But client doesn't know if any damage has been applied, because he do not get any notification, because property was not replicated.

avatar image AnxGotta Jul 23 '14 at 11:53 AM

Could you elaborate on "constant damage" please?

avatar image iniside Jul 23 '14 at 12:26 PM

Damage value doesn't change.

avatar image AnxGotta Jul 23 '14 at 12:39 PM

Ah, I see. Do you need to replicate damage this way? Usually you replicate the players health to all the clients and do all the damage related work on the server... there is really no need to replicate a "doDamage" value.

The reason I'm discussing this with you so much is because this situation sounds odd and there might be a better way to implement it.

avatar image iniside Jul 23 '14 at 03:09 PM

I need to replicate damage, because I want to give client chance to display it directly. It's only replicated to player who caused it.

avatar image AnxGotta Jul 23 '14 at 04:52 PM

I would research this a bit man. Damage in UE4

avatar image iniside Jul 23 '14 at 05:00 PM

I'm not using unreal build damage system. I have written my own from scratch ;).

Besides, I still would like to know, if it is possible to force replication on property, just for the sake of knowing it.

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

3 answers: sort voted first

Try this (Engine version 4.1):

Add Replicated tag to your propety:

 UPROPERTY(Replicated, Category="CategoryName")
 FStructType StructPropertyName;

Define replication in cpp file:

 void AYourClass::GetLifetimeReplicatedProps(TArray<FLifetimeProperty>& OutLifetimeProps) const
 {
     Super::GetLifetimeReplicatedProps(OutLifetimeProps);
 
     DOREPLIFETIME(AYourClass, StructPropertyName);
 }

Header definition is not needed for this method. Hope this help. Details: WIKI

more ▼

answered Jul 23 '14 at 10:50 AM

avatar image

mpo
583 23 15 48

avatar image iniside Jul 23 '14 at 10:54 AM

Well it will just replicate, property, when value on it changes ;).

I want to replicate it even if value haven't changed.

avatar image mpo Jul 23 '14 at 01:52 PM

Yeah, now I see your point (comments) :)

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

If you really want to do it this way, as per our conversation through comments, you could use a Server or Client RPC (remote procedure call).

You create a function that gets called on the server from the client, and another that gets called on the clients from the server. Just call this from your Tick function.

THIS is the main page for functions and their specifiers from the docs.

THIS is the Server RPC information from the docs.

THIS is the Client RPC information from the docs.

Edit: the Client RPC might not do what you want... The function is only executed on the client that owns the Object the function belongs to. I'm not sure if this fits your implementation. If not, there might be no way to do what you want without modifying the engine source. Need clarification on this though.

Edit2: Take a look at this for damage info LINK

more ▼

answered Jul 23 '14 at 12:43 PM

avatar image

AnxGotta
1.6k 61 45 237

avatar image iniside Jul 23 '14 at 05:31 PM

I already had tried this, and it's not what I needed. My issues is that when doing Client RPC might be out of sync. When properties do change, there is no way to predict when, they will be replicated to client, and RPC all might force client to work on oudated data, untill next replication tick.

That is why you want to use RepNotifies on in such case.

avatar image WCode Jul 24 '14 at 08:22 AM

Edit: the Client RPC might not do what you want... The function is only executed on the client that owns the Object the function belongs to.

You can use NetMulticast and the it will be called by all clients.

 There is another special type of RPC function type called Multicast. Multicast RPCs are designed to be called from the server, and then executed on the server as well as all currently connected clients. To declare a multicast function, you simply use the NetMulticast keyword: 

See ***here*** for more info.

avatar image iniside Jul 24 '14 at 08:34 AM

It's the same issue ;). The only difference is that Multicast is call on all clients which are relevant, to actor. And I really don't need that.

If I would wan't to call it on all clients I would still want to use RepNotify, just with without any replication conditions.

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

So I read through all of your comments and other answers. I think I have an idea for you to think about for your unique case, consider this:

Stay ahead of the calculation by pre-calculating the damage for the next interval. So right after damage is applied, calculate your next damage and presend it. So basically, send from the server to the client, 1) time for the next damage tick, and that next damage amount.

That is the general gist, of the idea. There is alot more to do with it, but if you understand that core idea, it can help with sync issues. I use a similar technique for keeping animation events timed from server to client in an another project.

Hope that helps. ;)

more ▼

answered Jul 24 '14 at 11:01 AM

avatar image

Devero
2.3k 114 62 235

(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