How to fix "NavLinkProxy's ReceiveSmartLinkReached event not triggered in C++"

Hi :smiley:
i had get some trouble about this issue and as you might knew, there is not much docs or topic about NavLinkProxy in detailed.
therefore i couldn’t find any single topic about it. i hardly kind of solved problem and i want to leave a note for someone has same problem like i had.
before get into it, as you already noticed it. i have really poor English skill, so please excuse my Eng and if you couldn’t get what i said or get offended somehow, please tell me :slight_smile:
and if i was wrong about some point please correct me.
hope this help some people

---- What is the problem ? ----
if you make your own Custom-NavLinkProxy class in C++ which has ANavLinkProxy as parent and you just override ReceiveSmartLinkReached event, that will not triggered.
it it because of some unique architecture of how it made and how it works, and i want to explain about it and how to fix it to trigger your own ReceiveSmartLinkReached event.

make your Custom-NavLinkProxy class in C++ might not necessary and you may can just make blueprint one instead of C++ and that will works just great.
and therefore this note might useless :d. but as you know some works be done so easier on C++ and working with C++ is so much fun :stuck_out_tongue:

---- How to fix the problem ? ----
i will tell you the fix way and i’ll explain about it later.

  1. override ‘NotifySmartLinkReached’ and ‘ReceiveSmartLinkReached’ event.
    of course you need to override this to make your code :stuck_out_tongue:

  2. include ‘NavLinkCustomComponent.h’, ‘PathFollowingComponent.h’ and ‘Controller.h’.
    the directory is like below. it might change at future so if directory isn’t correct, see the unreal doc.
    ‘NavigationSystem/Public/NavLinkCustomComponent.h’
    ‘Navigation/PathFollowingComponent.h’
    ‘GameFramework/Controller.h’

  3. put below code on your Custom-NavLinkProxy classes initializer.


GetSmartLinkComp()->SetMoveReachedLink(this, &** /*your class name*/**::NotifySmartLinkReached);

you need make your exception check part if you want to :stuck_out_tongue:

  1. put below code on your Custom-NavLinkProxy classes NotifySmartLinkReached event.

UPathFollowingComponent* PathComp = Cast<UPathFollowingComponent>(PathingAgent);
    if (PathComp)
    {
        AActor* PathOwner = PathComp->GetOwner();
        AController* ControllerOwner = Cast<AController>(PathOwner);
        if (ControllerOwner)
        {
            PathOwner = Cast<AActor>(ControllerOwner->GetPawn());
        }

        ReceiveSmartLinkReached(PathOwner, DestPoint);
        OnSmartLinkReached.Broadcast(PathOwner, DestPoint);
    }

  1. the fun part ! write your own ReceiveSmartLinkReached event yay~

---- What the fix steps does for ? ----
i believe unreal dev team are smart and working so hard so they intended something from it but the way ANavLinkProxy made is quite odds.
the first main reason of why Receive event not triggering is, ReceiveSmartLinkReached isn’t a virtual function and engine doesn’t call it from child class either.

i will tell you the call flow. as many people would, smart link is there main concern so it focused about smart link not simple link.
the ANavLinkProxy has UNavLinkCustomComponent in it as a ‘Smart Link’.
and UNavLinkCustomComponent has ‘function pointer’(or you can call it as function delegate i guess. i don’t know about delegate though) like thing in it for store NotifySmartLinkReached function’s address.
and if Agent(AI) want to use the Link while they following paths, they trigger UNavLinkCustomComponent’s OnLinkMoveStarted function which will call NotifySmartLinkReached event that stored inside ‘function pointer’ like thing.
then finally NotifySmartLinkReached event calls ReceiveSmartLinkReached event which you put your custom behavior code.

so that is how it flows and where ReceiveSmartLinkReached calls and why it doesn’t trigger your own event.
for fix the problem, you need to change the ‘function pointer’ like thing to your own event and Fix Step 3 is about that.
get smart link and set ‘function pointer’ like thing as your own event.

and Fix Step 4 is since ReceiveSmartLinkReached is called by NotifySmartLinkReached, you need to override NotifySmartLinkReached and that is what this step does.

---- Finish ----
so there you go :smiley:
that is how you make your C++ Custom-NavLinkProxy class trigger ReceiveSmartLinkReached event normally and why you need these steps for it.

during write this topic, i thought that you may can just make ‘Jump’ or ‘High Jump’ like function on C++ and make blueprint from that then just simply override ReceiveSmartLinkReached on blueprint and call C++'s ‘Jump’ or ‘High Jump’ like things.
and that makes this topic totally useless :'d.
but i already finished writing it so i’ll just praying and hope this topic helps and maybe teach some one :smiley:

unreal community always generously taught and helped me a lot.
i was trying to giving back some to community but sadly only i can do is just suck all the ‘information juice’ i can take and put kinda useless tips for billing.

anyway big thanks to unreal community and thanks for reading.
hope you all have a nice day :slight_smile:

1 Like

This was working like a charm, but I’ve got a problem since I updated to 4.21:

Fixed it this way: