SetTarget

method
SetTarget<public>(Agent: agent): void

Set the supplied `Agent` as the turret's target. * The target will only change if `Agent` is within the activation radius, has direct line-of-sight to the turret, is on a targetable team as determined by `Possible Targets`, and is not Down But Not Out.

Module
/Fortnite.com/Devices
Declared in
automated_turret_device
Source
fortnite

Used in

# This function starts everything.
    OnBegin<override>()<suspends> : void =
        # We tell the Step Modulator to begin running through its steps.
        # It will cycle through each step and send values to any
        # connected devices as wired in the UEFN editor.
        # note: Step Modulator device connections (target device + parameter)
        # are configured via editor wiring, not a SetTarget() call in Verse.
        StepMod.Enable()

        # Small pause to let the devices settle after Enable() is called.
        Sleep(0.1)
# Store who walked in so other functions can reference the target.
            set CurrentTarget = option{Agent}

            # Set the Spire's target to the agent who walked in.
            # Analogy: The boss locking eyes with you. Now it only attacks you.
            # This makes the fight fairer (and more personal) than random attacks.
            SpireDevice.SetTarget(Agent)

            # Cast to fort_character to read the player's name for the debug log.
            # Analogy: The announcer shouting the challenger's name.
            if (FortChar := Agent.GetFortCharacter[]):
                Print("Target locked on: " + FortChar.GetDisplayName())
GamePlay / Security Alarm Device verse-source
for (Turret : AutomatedTurrets):
            Turret.SetTarget(Target)

    # Clears target from all turrets
    ClearTurretsTarget() : void =
        for (Turret : AutomatedTurrets):
            Turret.ClearTarget()
MissionSystem / Mission Controller verse-source
Tracker.Assign(Agent)
                    if(Tracker.IsActive[Agent]):
                        Logger.Print("Tracker was not active for agent but has been reassigned")
                    else:
                        Logger.Print("Tracker is not active for agent, Reassigning tracker failed", ?Level:=log_level.Warning)
            # Set target value for this part
            Tracker.SetTarget(Part.TrackerTarget)
            # Restore the tracker value
            Tracker.SetValue(Agent, SaveValue)
            # Set tracker title - use custom or default
            if(GetTrackerTitle:= Part.TrackerTitle?): 
                Logger.Print("Updating Tracker title: {GetTrackerTitle}")
                Tracker.SetTitleText(StringToMessage(GetTrackerTitle))