NPC death/despawn causes memory limit error

Hello,

since the last update i’m encountering an error with my custom NPCs.

They are custom NPCs with custom verse behavior. They do things, and at the end to take out the npc from the map i’m teleporting it out of sight, then killing it.

After that, i’m having this error :

LogVerse: Error: VerseRuntimeErrors: Verse unrecoverable error: ErrRuntime_MemoryLimitExceeded: Exceeded memory limit(s).
Truncated callstack follows:

 LogVerse: Error: VerseRuntimeErrors: Verse unrecoverable error: ErrRuntime_MemoryLimitExceeded: Exceeded memory limit(s).
Truncated callstack follows:
    AI_npc?tions_component:NavigateTo(:navigation_target,:?MovementType:movement_type = ...,:?ReachRadius:float = ...,:?AllowPartialPath:logic = ...) (Unknown source)  (Source: Unknown(0,0, 0,0))
    task:PC_Customer2_2_Claim1$ExecuteCommand(:command,:int,:int,:int,:int):Update (Unknown source) (Source: Unknown(0,0, 0,0))

The unknown source makes me think that the script is still running somehow when the npc doesn’t exist anymore.
There is my code after which the error appears

if(NextPoint:= PathFollowed[PathIndex]):
  NavTarget := MakeNavigationTarget(NextPoint.GetTransform().Translation)    
  NavResult := Navigatable.NavigateTo(NavTarget, ?MovementType:=movement_types.Walking)

  if(PathIndex < PathFollowed.Length-1):   
       if(NavResult = navigation_result.Reached):                               
           set PathIndex+=1
       else:

           Loc:= OutOfMap.GetTransform().Translation
           LocRotation:= OutOfMap.GetTransform().Rotation 
                                     
           if(Character.TeleportTo[Loc,LocRotation]){}
              set GM.CustomersGroup1Spawned=false 
              Character.Damage(100.0)

With this code, i’m making my NPC following a defined path, if it’s reaching the end of it, then i teleport it to my “OutOfMap” location, tell my GameManager that the NPCGroup is not spawned anymore and damaging the character to kill npc.

If you have any idea how to solve this. I’m on it for 2 days now without finding anything

1 Like