[STABILITY] NPC behaviour has changed/broken for existing maps

Is there any update about this? I know npc spawner in on early access but our team is seriously evaluating whether to avoid using this device despite the potential, as the condition is very poor.

1 Like

hey friends, I was able to get my navigation working by moving the declaration of my NPC’s navigation_target outside of the scope of the NavigateTo() function, and making it an uninitialized variable instead of a const. Then I set it in a race between it and a Sleep function. My NavigateTo function looks like this now :

#Moved to outside of NavigateTo()
  var NavTarget : navigation_target

    NavigateToNextPatrolPoint(Agent : agent, Navigatable : navigatable) <suspends>: void = 

        loop:
            # Get a vector 3 from our array of Goal Destinations
            if(GoToPoint := GoalDestinations[CurrentPatrolPoint]):

                # Debug meessage
                if(ShowAINavDebug?):
                    Print(first_npc_behavior_message_module.OnNavigateBeginMessage(Agent,GoToPoint.X,GoToPoint.Y,GoToPoint.Z), ?Duration := AIDebugDrawTime)

                
                **# Create a Navigation Target from the next Goal Destination - added race to ensure it is set before proceeding**
**                race:**
**                    block:**
**                        set NavTarget = MakeNavigationTarget(GoToPoint)**
**                        Navigatable.Wait(?Duration := 0.0)**
**                    Sleep(Inf)**
                    
                # If the debug flag is enabled draw a box around the location the NPC is moving toward for visual
                # validation that it is where you expect.
                if(ShowAINavDebug?):
                    DrawDebugLocation(GoToPoint)
                
                NavResultGoTo := Navigatable.NavigateTo(NavTarget, ?MovementType:= movement_types.Running, ?ReachRadius := ReachRadius)
                if (NavResultGoTo = navigation_result.Reached):

                    # Check if final patrol point has been reached and end loop
                    if(CurrentPatrolPoint = GoalDestinations.Length-1):
                        if(ShowAINavDebug?){Print("Final Patrol Point reached")}
                        return
                    # Otherwise increment the patrol point tracker and re-run this function
                    else:
                        set CurrentPatrolPoint += 1

                # Check to see if something has interfered with the NPC reaching the intended location and print a
                # message to the output log.
                else if (NavResultGoTo <> navigation_result.Reached):

                    if(ShowAINavDebug?):
                        Print(first_npc_behavior_message_module.OnNavigateErrorMessage(Agent,GoToPoint.X,GoToPoint.Y,GoToPoint.Z), ?Duration := AIDebugDrawTime)
                        PrintNPCB("Creep Blocked!")

EDIT : Although my fix did patch the navigation issues, unfortunately I found a bug in testing: the NPCs that are blocked by a player built wall will only attack the wall 1 time in attempt to path through it, after which they stop trying. Before the bugs, the NPCs would attack indefinitely until the wall was destroyed and they could continue on their path.

Will be trying working on that one later but I think I’ve done all I can in regards to this issue

5 Likes

This is similar to my issue. NPC navigation no longer is able to address walls as well as before. Though in my case, I would expect it to use a door near the wall. it now just runs into the wall and blocks itself.

1 Like

Seems to be fixed now :slight_smile:

2 Likes

It has not on my end.

likewise, my island still not working as expected

edit : scratch that, its working :slight_smile: adjusted my code slightly but it works great now

1 Like

looks like fixed for me too. thanks epic!

1 Like

if your code is still not firing and you want to post it maybe we can help?

loop:
            Print("Redirecting")
            var NRTarget : navigation_result = navigation_result.Unreachable
            #race:
            set NRTarget = Navigatable.NavigateTo(NavigationTarget, ?MovementType:=movement_types.Running)
                #Sleep(20.0)    
            #var NRTarget : navigation_result = Navigatable.NavigateTo(NavigationTarget, ?ReachRadius := Radius, ?MovementType:=movement_types.Running)
            utils.NRToString(NRTarget)
            if(NRTarget = navigation_result.Reached):
                break

It’s nothing too different. It’s taken from the Guard AI NPC script provided by EPIC staff. I tried the advice from the forum and did a race condition with different time values (i.e. constantly redirect the NPC as it navigates). The original version which was just to loop nonstop constantly redirecting would work. The test case is to place an item in the middle of a closed room with doors and the NPC outside of the room. The prior patch behavior would have the NPC open the door but this is no longer the case.

1 Like

Hi

Thank you for the roundabout both of you @kirit01011 @TelesphorosGames

What I found today it that there are several structures where the NPC can not transit. Some of them are literally floors. I recomend test which structures you can use for your the npc before designing the level.

Ya I was aware of that issue before. There are certain structures in the prefab buildings which if you just turn off “Affect navigation” option in the details will allow your NPC to path through it.

But this still does not solve for why the NPC will now just run straight into a wall instead of using sidedoors like before.

is there an update on this issue?

Adding a daily ping here that I’m still looking for a solution or a note.