GetNavigatable

method
(InCharacter: fort_character).GetNavigatable<public>()<transacts><decides>: navigatable

Get the navigatable interface for the specified character

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

Used in

OnDamaged(Result : damage_result) : void =
        if:
            Agent := GetAgent[]
            Character := Agent.GetFortCharacter[]
            Navigatable := Character.GetNavigatable[]
            Focus := Character.GetFocusInterface[]
            Attacker := agent[Result.Instigator?]
            AttackerChar := Attacker.GetFortCharacter[]
        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 (GoblinCharacter := GoblinAgent.GetFortCharacter[]):
                if (GoblinNav := GoblinCharacter.GetNavigatable[]):

                    # 3. GET THE PLAYER'S POSITION
                    # Cast 'Agent' to a fort_character so we can call GetTransform().
                    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!")
FollowOwner(Character : fort_character, Owner : agent, Sidekick : npc_sidekick_component)<suspends> : void =
        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)
NpcSystem / Npc Data verse-source
NewNPCData := npc_data{
            InAgent := InAgent
            InCharacter := InCharacter
            InBehavior := InAgent.GetNPCBehavior[]
            Navigatable := InCharacter.GetNavigatable[]
            InFocus := InCharacter.GetFocusInterface[]
            InAnimation := InCharacter.GetPlayAnimationController[]
            # Initialize new NPCSessionData
            SessionData := npc_session_data{
                SpawnPoint := InCharacter.GetTransform().Translation
                LastKnownPosition := InCharacter.GetTransform().Translation
            }
            # Initialize new NPCPersistentData
            SavedData := npc_persistent_data{
                NpcName := "Unknown"  # Unknown NPC name set during runtime
                SpawnPoint := InCharacter.GetTransform().Translation
            }
NpcSystem / Npc Statemachine verse-source
if (Player := Agent.GetFortCharacter[].GetPlayer[]):
                        if (Distance < ClosestPlayerDistance):
                            set ClosestPlayerAgent = option{Agent}
                            set ClosestPlayerDistance = Distance
                    else:
                        if (Agent.GetFortCharacter[].GetNavigatable[]):
                            if (Distance < ClosestNPCDistance):
                                set Closest = option{Agent}
                                set ClosestNPCDistance = Distance
    
        return (Closest?, ClosestNPCDistance, ClosestPlayerAgent?, ClosestPlayerDistance)  
 #>
NpcSystem / GoDoDevice verse-source
LetsNavigate(InAgent: agent, Do: to_do_item, ?ByLocation: ?vector3 = false, ?ByAgent: ?agent = false )<suspends>:void=
        # We need to check if the agent has a navigatable component
        if(InNavigatable := InAgent.GetFortCharacter[].GetNavigatable[]):
            NavigationTarget := {
                if(Location := ByLocation?):
                    MakeNavigationTarget(Location)
                else if(Agent := ByAgent?):
                    MakeNavigationTarget(Agent)
                else:
                    MakeNavigationTarget(InAgent)
            }
            NavigationResult := InNavigatable.NavigateTo(NavigationTarget, ?MovementType := Do.NavigateBy.Settings.MovementType, ?ReachRadius := Do.NavigateBy.Settings.ReachRadius, ?AllowPartialPath := Do.NavigateBy.Settings.AllowPartialPath)
            if(NavigationResult = navigation_result.Reached):
                LetsDo(InAgent, Do)
            else if(NavigationResult = navigation_result.PartiallyReached):
                Logger.Print("{Do.ID} - Navigation to the object was partially reached, playing interrupted sequence", ?Level:=log_level.Normal)
                PartialReached(InAgent, Do)