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"

Office Holiday

Epic Games' offices will be on holiday from June 22nd to July 7th. During this period support will be limited. Our offices will reopen on Monday, July 8th. 

ReplicatedUsing function never gets called

Hello everyone!

Today i was trying to execute a function on variable value change,but UE doesn't execute the function,what am i doing wrong?

my .h :

  UFUNCTION()
  void testrepfunc();
     
 UPROPERTY(VisibleDefaultsOnly, BlueprintReadWrite, Category = "TESTCATEGORY", ReplicatedUsing = testrepfunc)
             int32 testint = 0;

my .cpp :

 void MyCharacter::testrepfunc()
 {
     GEngine->AddOnScreenDebugMessage(-1, 20.0f,FColor::Orange, "Test");
 }


 void MyCharacter::GetLifetimeReplicatedProps(TArray< FLifetimeProperty > & OutLifetimeProps) const
 {
    // do i need to insert something here?
 }


Blueprint variable change (triggerbox) alt text

Product Version: UE 4.11
Tags:
1.png (162.4 kB)
more ▼

asked May 13 '16 at 04:53 PM in C++ Programming

avatar image

iSpakkio
200 9 10 20

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

1 answer: sort voted first

You indeed need to add

 Super::GetLifetimeReplicatedProps(OutLifetimeProps);
 DOREPLIFETIME(MyCharacter, testint);

more ▼

answered May 14 '16 at 08:35 AM

avatar image

cageman
673 30 33 65

avatar image iSpakkio May 14 '16 at 01:25 PM

Hey,Thanks for your answer!

I Modified the function like this :

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


 

but still, the testrepfunc() doesn't get called whenever testint changes value.

Got any idea? Please let me know! :)

avatar image Streliteela Jul 05 '18 at 03:21 AM

You need to check whether this function is called on Server or on Client. If you want the server to call that function, you have to do so manually. Please check this thread that is very helpful.

(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