MakeNavigationTarget

method
MakeNavigationTarget<native><public>(Agent: agent): navigation_target

Generate a navigation_target from an agent.

Module
/Fortnite.com/AI
Declared in
AI
Source
fortnite

Used in

then:
            MyPos := Character.GetTransform().Translation
            ThreatPos := AttackerChar.GetTransform().Translation
            # Direction pointing FROM the threat TO us, normalized, then pushed out.
            Away := (MyPos - ThreatPos)
            FleePoint := MyPos + Away * FleeDistance
            Target := MakeNavigationTarget(FleePoint)
            Print("Villager spooked — fleeing!")
            # Keep looking at the attacker while we run (focus never completes
            # on its own, so spawn it as its own fiber).
            spawn{ Focus.MaintainFocus(Attacker) }
            spawn{ RunAway(Navigatable, Target) }
if (PlayerCharacter := Agent.GetFortCharacter[]):
                        TargetPosition := PlayerCharacter.GetTransform().Translation

                        # Create a Navigation Target from that position.
                        # A Navigation Target is just a waypoint in the game world.
                        NavTarget := MakeNavigationTarget(TargetPosition)

                        # 5. TELL THE GOBLIN TO MOVE!
                        # NavigateTo is a suspends function, so we spawn a concurrent task for it.
                        # This lets the rest of the island keep running while the goblin walks.
                        spawn{ GoblinNav.NavigateTo(NavTarget) }

                        Print("Goblin has been dispatched!")
if (Navigatable := Character.GetNavigatable[]):
            loop:
                Target := MakeNavigationTarget(Owner)
                Result := Navigatable.NavigateTo(Target, ?ReachRadius := FollowRadius)
                if (Result = navigation_result.Reached):
                    # Caught up — play a happy emote (failable: may be busy).
                    if (Sidekick.PlayReaction[sidekick_reaction.Happy]):
                        Print("Sidekick caught up — playing Happy!")
                    Navigatable.Wait(?Duration := 1.5)
JoustingGame / Elephant Npc Behavior verse-source
if(TagResult := TagController.GetRandomTag[InAgent, TagSearchCriteria, 10000.0]):
                    TagLocation := TagResult(0)
                    NavigateToLocation := MakeNavigationTarget(TagLocation)
                    NavResult := spawn {NpcData.Navigatable.NavigateTo(NavigateToLocation, ?MovementType:=movement_types.Walking)}
                    NavResult.Await()
                    sync:
                        Sleep(1.0)
                        PlayAnimation(InAgent, AnimationList.Drink)            
                        #DogAudio.PlayAudio(InAgent, "Drink")
                        PlayAudioNPC(InAgent, "Drink", DogAudioSFX)
                    # We use a ChanceToPlay of 50% to play the animation again.
                    ChanceToReplay := GetRandomInt(0,1)
                        if( ChanceToReplay = 1):
                            sync:
                                PlayAnimation(InAgent, AnimationList.Drink)
                                #DogAudio.PlayAudio(InAgent, "Drink")
                                PlayAudioNPC(InAgent, "Drink", DogAudioSFX)
                                Sleep(1.5)
NpcSystem / Civilian Npc Behavior verse-source
if(TagResult := TagController.GetRandomTag[InAgent, TagSearchCriteria, 10000.0]):
                            TagLocation := TagResult(0)
                            NavigateToLocation := MakeNavigationTarget(TagLocation)
                            NavResult := NpcData.Navigatable.NavigateTo(NavigateToLocation, ?MovementType:=movement_types.Walking)
                            #NavResult.Await()
                            Sleep(1.0)
                            PlayAnimation(InAgent, AnimSeq_Drinks)
                            Sleep(2.0)                
                            NPCAudio.PlayAudio(InAgent, "Drinks")
                            PlayAnimation(InAgent, AnimSeq_Drinks)
                            Sleep(2.0)
                            PlayAnimation(InAgent, AnimSeq_Drunk)
NpcSystem / Npc Statemachine verse-source
if (ObjectLocation := MaybeObjectLocation?):
                # Navigate to the object
                NavigationTarget := MakeNavigationTarget(ObjectLocation)
                    if (DebugAI?):
                        DebugNpc("{NPCName} - Navigating to {ObjectLocation} - {(if (SelectTagBy = TagFindOptions.Closest) then "closest" else "random")} object with tag", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.CadetBlue)
                    Logger.Print("{NPCName} - Navigating to {ObjectLocation} - {(if (SelectTagBy = TagFindOptions.Closest) then "closest" else "random")} object with tag")

                    race:
                        set NavResults = NpcData.Navigatable.NavigateTo(NavigationTarget, ?MovementType := (/Fortnite.com/AI/movement_types:)Walking, ?ReachRadius := 100.0, ?AllowPartialPath := true)
                        block:
                            Sleep(Timeout)
                            Logger.Print("{NPCName} - GoDo - Navigation to the object with tag failed, timeout", ?Level := log_level.Warning)
                            if (DebugAI?):
                                DebugNpc("{NPCName} - Navigation to the object with tag failed, timeout", ?Duration := AIDebugDrawTime, ?TextColor := NamedColors.Red)
                            #return TaggedObject
                    # Check if the navigation was successful
                    NavigateResult := NavResults
                        if (NavigateResult = navigation_result.Reached):
                            # Perform actions on the object
                            race:
                                FocusOnObject := NpcData.InFocus.MaintainFocus(ObjectLocation)
                                block:
                                    Sleep(1.0)
                                    sync:
                                        PlayAnimation(NpcData.InAgent, PlayAnimSeq)
                                        NPCAudio.PlayAudio(NpcData.InAgent, PlaySound)
                                        block:
                                            #if: 
                                                NPCLookingAt := NpcData.InCharacter.GetViewRotation()
                                                NPCLocation := NpcData.InCharacter.GetTransform().Translation
                                            #then:
                                                set NPCFinalLocation = option{NPCLocation}
                                                PlayVFX(PlayFX, NPCLocation, ?VFXRotation := NPCLookingAt, ?VFXDelay := 0.0)

                        else if (NavigateResult = navigation_result.PartiallyReached):
                            Logger.Print("{NPCName} - GoDo - Navigation to the closest object was partially reached, playing interrupted sequence", ?Level:=log_level.Normal)
                            PlayAnimation(NpcData.InAgent, AnimSeq_CanNotReach)
                            NPCAudio.PlayAudio(NpcData.InAgent, "CanNotReach")
                        else if (NavigateResult = navigation_result.Interrupted):
                            Logger.Print("{NPCName} - GoDo - Navigation to the closest object was Interrupted, playing interrupted sequence", ?Level:=log_level.Normal)
NpcSystem / Hobo Npc Behavior verse-source
if(TagResult := TagController.GetRandomTag[InAgent, TagSearchCriteria, 10000.0]):
                            TagLocation := TagResult(0)
                            NavigateToLocation := MakeNavigationTarget(TagLocation)
                            NavResult := spawn {NpcData.Navigatable.NavigateTo(NavigateToLocation, ?MovementType:=movement_types.Walking)}
                            NavResult.Await()
                            Sleep(1.0)
                            PlayAnimation(NpcData.InAgent, AnimSeq_Drinks)
                            Sleep(2.0)                
                            NPCAudio.PlayAudio(InAgent, "Drinks")
                            PlayAnimation(NpcData.InAgent, AnimSeq_Drinks)
                            Sleep(2.0)
                            PlayAnimation(NpcData.InAgent, AnimSeq_Drunk)
NpcSystem / Animal Npc Behavior verse-source
if (DebugAI?) then DebugNpc("{NPCName} - Returning to player", ?Duration := 5.0, ?TextColor := NamedColors.Cyan)
                if:
                    FC := CommandAgent.GetFortCharacter[]
                    PlayerLoc := FC.GetTransform().Translation
                then:
                    NavTarget := MakeNavigationTarget(PlayerLoc)
                    NPCData.Navigatable.NavigateTo(NavTarget,
                        ?MovementType := (/Fortnite.com/AI/movement_types:)Running,
                        ?ReachRadius := 200.0, ?AllowPartialPath := true)
                # Re-leash to player
                if (Leashable := NPCData.InCharacter.GetFortLeashable[]):
                    Leashable.SetLeashAgent(NPCData.InAgent, PetFollowInnerRadius, PetFollowOuterRadius)
NpcSystem / Npc Movement verse-source
AgentLocation := GoToAgent.GetFortCharacter[].GetTransform().Translation
        then:
            if(Variation := Accuracy?):
                set GoToPoint = AgentLocation + vector3{X := GetRandomFloat(-Variation,Variation),
                                                Y := GetRandomFloat(-Variation,Variation),
                                                Z := 0.0 } 
            # set NavTargetStart = MakeNavigationTarget(GoToPoint)
            else: 
                Variation := 0.0
                set GoToPoint = AgentLocation + vector3{X := GetRandomFloat(-Variation,Variation),
                                                Y := GetRandomFloat(-Variation,Variation),
                                                Z := 0.0 } 
            #   set NavTargetStart = MakeNavigationTarget(GoToPoint)
NpcSystem / Vehicle Npc Behavior verse-source
if(TagResult := TagController.GetRandomTag[InAgent, TagSearchCriteria, 10000.0]):
                        TagLocation := TagResult(0)
                        NavigateToLocation := MakeNavigationTarget(TagLocation)
                        NavResult := spawn {NpcData.Navigatable.NavigateTo(NavigateToLocation, ?MovementType:=(/Fortnite.com/AI/movement_types:)Walking)}
                        NavResult.Await()
                        Sleep(1.0)
                        PlayAnimation(NpcData.InAgent, AnimSeq_Drinks)
                        Sleep(2.0)                
                        NPCAudio.PlayAudio(NpcData.InAgent, "Drinks")
                        PlayAnimation(NpcData.InAgent, AnimSeq_Drinks)
                        Sleep(2.0)
                        PlayAnimation(NpcData.InAgent, AnimSeq_Drunk)