Boss AI NPC's in UEFN are not targeting the appropriate player

My Boss AI NPC’s are not targeting the player that activates that mutator zone. Instead they just target one particular player for the entire game and every boss just teleport to that one player instead. Is there any way to fix this?

using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /Fortnite.com/Characters }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Playspaces }

BossDevice := class(creative_device):

PlayerChar : ?agent = false

@editable
Bossprop : creative_prop = creative_prop{}

@editable
Zonedevice : mutator_zone_device = mutator_zone_device{}


ProptranslationAxis : vector3 = vector3:
    X := 0.0
    Y := 0.0
    Z := -1.0


OnBegin<override>()<suspends>:void=
     Zonedevice.AgentEntersEvent.Subscribe(OnTriggered)


OnTriggered(Agent: agent):void =
    spawn{FollowPlayer()}


FollowPlayer()<suspends>:void = 

    loop:
        Sleep(0.01)
        if (PlayerList := GetPlayspace().GetPlayers(), FortCharacter := PlayerList[0].GetFortCharacter[]):
            Playerpostion : vector3 = FortCharacter.GetTransform().Translation
            Proptranslation : vector3 = Bossprop.GetTransform().Translation

            VectorToPlayer : vector3 = Playerpostion - Proptranslation

            RadiansVectorToPlayer: float = ArcTan(VectorToPlayer.X, VectorToPlayer.Y) - (PiFloat / 2.0)

            NewRotation : rotation =MakeRotation(axis := ProptranslationAxis, AngleRadians := RadiansVectorToPlayer)

            Bossprop.MoveTo(Playerpostion, NewRotation, 1.0)

        else:
             break

@JoeBroPro Thank you for your report! We would like to look into this further, would you be able to submit a bug report using the form available here? Fortnite Creative

In your code, you’re not doing anything with the agent that’s given to you from the mutator zone (OnTriggered). When you get this agent after it enters the zone, you need to pass it to the FollowPlayer function where the optional gets set to the agent for the prop to MoveTo(). Right now you have it so it only goes for Player 1 in the game. So if Player 2 steps in mutator zone, it’ll still go for Player 1.

1 Like

Gotcha, that makes sense. Do you know any similar code I can look at that does something like this? I really don’t understand verse or coding in general and maybe a visual could help me.

Thanks!

@EV_WAKA

Sorry for the delay, I’d checkout Wahlbeck Warforge’s channel.