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"

Function isn't getting called

I'm working on a fps and took some weapon code from the shooter game but I've run into a very strange issue where a function is getting called but it never gets executed. Here's what's happening, my code calls ServerNotifyHit but ServerNotifyHit_Implementation never gets fired.

this is the function declaration

 /** server notified of hit from client to verify */
 UFUNCTION(reliable, server, WithValidation)
 void ServerNotifyHit(const FHitResult Impact, FVector_NetQuantizeNormal ShootDir, int32 RandomSeed, float ReticleSpread);

and here's where it tries to call the function. I used breakpoints and am using an onscreeen debug msg so i know for sure that its getting to the point where it tries to call ServerNotifyHit

 void Aweapon_pistol::ProcessInstantHit(const FHitResult& Impact, const FVector& Origin, const FVector& ShootDir, int32 RandomSeed, float ReticleSpread)
 {
     if (MyPawn && MyPawn->IsLocallyControlled() && GetNetMode() == NM_Client)
     {
         // if we're a client and we've hit something that is being controlled by the server
         if (Impact.GetActor() && Impact.GetActor()->GetRemoteRole() == ROLE_Authority)
         {
             // notify the server of the hit
             GEngine->AddOnScreenDebugMessage(-1, 5.f, FColor::Red, FString("trying to call ServerNotifyHit()"));
             ServerNotifyHit(Impact, ShootDir, RandomSeed, ReticleSpread);
         }

header http://pastebin.com/raw.php?i=vucee2Ya

cpp http://pastebin.com/raw.php?i=81hRCpK9

Product Version: Not Selected
Tags:
more ▼

asked Sep 22 '14 at 06:08 PM in C++ Programming

avatar image

Chris528
332 21 21 36

avatar image Shadowriver Sep 22 '14 at 06:26 PM

Isn't "_Implementation" is used in blueprint related events?

avatar image Chris528 Sep 22 '14 at 06:35 PM

not in this case

avatar image Shadowriver Sep 22 '14 at 06:44 PM

Yea but as i know it only used in events, can tell me why it suppose to be called? Is it because "WithValidation"?

avatar image Chris528 Sep 22 '14 at 06:52 PM

i think because of server. https://answers.unrealengine.com/questions/77666/networking-c-withvalidation.html , that explains what "WithValidation" is for.

avatar image Shadowriver Sep 22 '14 at 07:01 PM

They saying about "_validate" not "_implmentation"

avatar image Chris528 Sep 22 '14 at 07:05 PM

its because of server

     /// This function is replicated, and executed on servers.  Provide a body named [FunctionName]_Implementation instead of [FunctionName];
     /// the autogenerated code will include a thunk that calls the implementation method when necessary.
     Server,
avatar image Shadowriver Sep 22 '14 at 10:14 PM

Ah ok, in this case UHT should generate the function body which calls implementation, you can study this generated code in Intimidate direcotry

avatar image Chris528 Sep 22 '14 at 11:13 PM

The thing is that it should, but its not. The generated file seems to be missing all that info also.

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

0 answers: sort voted first
Be the first one to answer this question
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