# focus\_interface.MaintainFocus now instantly completes

**URL:** <https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173>\
**Category:** Issues and Bug Reporting\
**Tags:** unreal-editor-for-fortnite, fortnite-creative, fixed, fortnite\
**Created:** [January 15, 2025, 10:48pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173 "2025-01-15T22:48:29Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![flyingpigbaby](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingpigbaby](https://forums.unrealengine.com/u/flyingpigbaby)\
**Post date:** [January 15, 2025, 10:48pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/1 "2025-01-15T22:48:29Z")

</div>

### Summary

In a recent update (potentially the last one?) focus\_interface.MaintainFocus no longer “Will never complete unless interrupted.”, this means that it won’t maintain focus at all, but more importantly it breaks race conditions early that it wouldn’t have before. This has broken a lot of NPC logic in one of behaviours as it now exits the race early causing my NPCs to not attack players at all.

Also, this isn’t just for new versions inside UEFN, this is live in public/private versions that haven’t been updated at all, I’ve checked my oldest from release from 21st December and that is now broken as well.

### Please select what you are reporting on:

Verse

### What Type of Bug are you experiencing?

AI

### Steps to Reproduce

Use .MaintainFocus inside a race along with another suspends function that should take time. E.g.

```auto
race
{
    block
    {
        FocusInterface.MaintainFocus(Target)
        Print("Should never reach here") # printed every tick in console
    }

    Sleep(1000.0)
}

```

### Expected Result

The function .MaintainFocus should never complete.

### Observed Result

The function .MaintainFocus completes instantly.

### Platform(s)

Windows

### Island Code

7142-4719-9129

---

<div class="post-metadata">

**Author:** ![Shabuway](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shabuway/32/1021794_2.png) [@Shabuway](https://forums.unrealengine.com/u/Shabuway)\
**Post date:** [January 15, 2025, 10:52pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/2 "2025-01-15T22:52:47Z")

</div>

Confirming that I also see this behavior. I imagine MaintainFocus is a pretty common call to rely on in race conditions, so this could be breaking a lot of maps. As a workaround I’ve wrapped MaintainFocus in an infinite loop. NPC’s appear to still be focusing.

```auto
loop:
  Focus.MaintainFocus(Target)
  Sleep(0.1)

```

---

<div class="post-metadata">

**Author:** ![Ograndejoojao](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Ograndejoojao](https://forums.unrealengine.com/u/Ograndejoojao)\
**Post date:** [January 16, 2025, 4:21am UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/3 "2025-01-16T04:21:01Z")

</div>

Also confirming that I’m seeing this behavior

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 4:25pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/5 "2025-01-16T16:25:32Z")

</div>

Investigating, which type of NPCs are you using? Which which type of spawner? Thanks!

---

<div class="post-metadata">

**Author:** ![Shabuway](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shabuway/32/1021794_2.png) [@Shabuway](https://forums.unrealengine.com/u/Shabuway)\
**Post date:** [January 16, 2025, 4:55pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/6 "2025-01-16T16:55:43Z")

</div>

I was seeing this using an NPC Spawner Device. The maintain focus call was inside of a custom NPC verse behavior script. There is an NPC character definition blueprint set to use the verse behavior, and the spawner set to use the blueprint.

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 6:23pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/7 "2025-01-16T18:23:28Z")

</div>

So far I cannot reproduce it with any NPC…  
Here is my test script, are you doing anything else?

```auto
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }
using { /Fortnite.com/Devices }
using { /Fortnite.com/Playspaces }
using { /Verse.org/Simulation }
 
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Verse.org/Colors }

look_at_behavior := class(npc_behavior):

    
    OnBegin<override>()<suspends>:void =

        if:
            Character:=GetAgent[].GetFortCharacter[]
            FocusInterface:=Character.GetFocusInterface[]
            Navigatable:= Character.GetNavigatable[]
        then:

            SourcePosition:=MakeNavigationTarget(Character.GetTransform().Translation)
            DestinationPosition:=MakeNavigationTarget(Character.GetTransform().Translation + vector3{ X:= 1000.0})
            loop:

                Result1:=Navigatable.NavigateTo(DestinationPosition, ?MovementType:=movement_types.Walking)
                if (Result1<>navigation_result.Reached):
                    Print("Navigation 1 Error ", ?Duration:=10.0, ?Color:=NamedColors.Red)
                else:
                    Print("Navigation 1 Success ", ?Duration:=10.0, ?Color:=NamedColors.Green)

                if:
                    Player:=creative_device{}.GetPlayspace().GetPlayers()[0]
                then:
                    Print("Start Maintain Focus on target", ?Duration:=10.0, ?Color:=NamedColors.Green)
                    race:
                        block
                        {
                            FocusInterface.MaintainFocus(Player)
                            Print("Should never reach here", ?Duration:=10.0, ?Color:=NamedColors.Red)
                        }
                        Sleep(5.0)
                    Print("End Maintain Focus on target", ?Duration:=10.0, ?Color:=NamedColors.Green)

                Print("Start Maintain Focus on position", ?Duration:=10.0, ?Color:=NamedColors.Green)
                race:
                    block
                    {
                        FocusInterface.MaintainFocus(Character.GetTransform().Translation + vector3{ Y:= 2500.0})
                        Print("Should never reach here", ?Duration:=10.0, ?Color:=NamedColors.Red)
                    }
                    Sleep(5.0)

                Print("Start Maintain Focus and navigate", ?Duration:=10.0, ?Color:=NamedColors.Green)
                race:
                    sync:
                        FocusInterface.MaintainFocus(Character.GetTransform().Translation + vector3{ Y:= -2500.0})
                        Navigatable.NavigateTo(DestinationPosition, ?MovementType:=movement_types.Walking)
                    Sleep(5.0)
                
                race:
                    Navigatable.NavigateTo(SourcePosition)
                    FocusInterface.MaintainFocus(Character.GetTransform().Translation + vector3{ Y:= 2500.0})
    

```

---

<div class="post-metadata">

**Author:** ![Shabuway](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shabuway/32/1021794_2.png) [@Shabuway](https://forums.unrealengine.com/u/Shabuway)\
**Post date:** [January 16, 2025, 6:47pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/8 "2025-01-16T18:47:10Z")

</div>

Interesting… I extended my NPC behavior a bit, so maybe there’s an edge case somewhere in there. I pasted some semi-cleaned up code below, but the gist is:

- I’ve added an interface (team\_targetable\_v2) to leverage a method, TargetTeam.
- Instead of telling the NPC what to do inside of OnBegin when it’s created, I first let it create itself, then use TargetTeam in some other code to tell the NPC what to do
- Other NPC behaviors will extend creep\_behavior\_default to override “TargetReached”
- The NPC will go through some logic of prioritizing who to walk towards, which results in “ValidTarget”
- In the code below you can see my workaround for the MaintainFocus finishing by adding a loop around it. Previously I just had MaintainFocus outside of the block on its own. I verified this was breaking by putting a print before and after MaintainFocus.

```auto
creep_behavior_default := class(npc_behavior, team_targetable_v2):

    @editable
    MyReachDistance : float = 500.0

    @editable
    MyMovementType : NPCMovementTypes = NPCMovementTypes.Run

    @editable
    MyMovementSpeedMultiplier : float = 1.0

    var NPCUtilities : npc_utilities = npc_utilities{}

    TargetTeam<override>(AttackLane : Lane, ?ForceAttackPlayers : logic = false)<suspends> : void =
        if:
            # Get the Agent (this NPC).
            Agent := GetAgent[]
            Character := Agent.GetFortCharacter[]
            Navigatable := Character.GetNavigatable[]
            Focus := Character.GetFocusInterface[]        
        then:
            loop:
                # If the NPC died then break the loop
                if (not Character.IsActive[]):
                    break

                # If we are overriding to target a player only, then choose the player. Otherwise follow
                # standard logic.
                MaybeClosestTarget := 
                    if (ForceAttackPlayers?, PlayerInLane := AttackLane.GetPlayersInLane()[0]):
                        option{PlayerInLane}
                    else:
                        NPCUtilities.GetClosestCreepTarget(AttackLane, Self)

                if:
                    ValidTarget := MaybeClosestTarget?
                    TargetDistance := NPCUtilities.CheckAgentDistance(ValidTarget, Self)
                    TargetDistance > MyReachDistance
                then:
                    var CreepReachedTarget : logic = false

                    race:
                        # Keep looking at the target
                        block:
                            loop:
                                Focus.MaintainFocus(ValidTarget)
                                Sleep(0.1)
                        block:
                            # If the target we're navigating to dies, then stop the race
                            loop:
                                Sleep(0.2)
                                if (not ValidTarget.GetFortCharacter[].IsActive[]):
                                    break
                        block:
                            # If we were targeting a player but there's now a guard, re-evaluate
                            if (not ForceAttackPlayers?, IsPlayer := player[ValidTarget]):
                                loop:
                                    Sleep(2.0)
                                    MaybeNewTarget := NPCUtilities.GetClosestCreepTarget(AttackLane, Self)

                                    if (NewTarget := MaybeNewTarget?, NewTarget <> ValidTarget):
                                        break
                            else:
                                # If we are already chasing a guard then let this thread wait
                                # This should never win the race.
                                Sleep(Inf)
                        block:
                            #Create a navigation target from ValidTarget
                            NavTarget := MakeNavigationTarget(ValidTarget)

                            ThisMovementType := if (MyMovementType = NPCMovementTypes.Run) then movement_types.Running else movement_types.Walking

                            # Tell the NPC to go to this spot within MyReachDistance. Method will wait here until we get a result.
                            NavResultGoTo := Navigatable.NavigateTo(NavTarget, ?MovementType:=ThisMovementType, ?ReachRadius := MyReachDistance)

                            if (NavResultGoTo <> navigation_result.Reached):
                                  # [Some logic here to try a backup for navigating]
                            else:
                                set CreepReachedTarget = true
                                
                    # If our race ended with reaching the target, make sure the creep has time to finish the TargetReached logic before restarting.
                    if (CreepReachedTarget?):
                        TargetReached(ValidTarget)

                # Sleep for the overall loop
                Sleep(1.0)

    # Override to perform custom behavior in subclass when we reached InTarget based in MyReachDistance.
    TargetReached(InTarget : agent)<suspends> : void=
        block:

```

---

<div class="post-metadata">

**Author:** ![Shabuway](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shabuway/32/1021794_2.png) [@Shabuway](https://forums.unrealengine.com/u/Shabuway)\
**Post date:** [January 16, 2025, 6:50pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/9 "2025-01-16T18:50:01Z")

</div>

Maybe the edge case here is calling MaintainFocus _after_ OnBeing() completes?

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 8:16pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/10 "2025-01-16T20:16:12Z")

</div>

I might have found something… if you change the order to put this at the end of the race, does it work?

```auto
                        # Keep looking at the target
                        block:
                              Focus.MaintainFocus(ValidTarget)
                              Print("Should never reach here 1", ?Duration:=10.0, ?Color:=NamedColors.Red)

```

---

<div class="post-metadata">

**Author:** ![Shabuway](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/shabuway/32/1021794_2.png) [@Shabuway](https://forums.unrealengine.com/u/Shabuway)\
**Post date:** [January 16, 2025, 8:41pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/11 "2025-01-16T20:41:12Z")

</div>

Unfortunately I still reproduce the issue with the MaintainFocus block at the end of the race. I tried both putting it in its own block, as well as just putting it as a single line inside of the race.

---

<div class="post-metadata">

**Author:** ![flyingpigbaby](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingpigbaby](https://forums.unrealengine.com/u/flyingpigbaby)\
**Post date:** [January 16, 2025, 9:14pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/12 "2025-01-16T21:14:01Z")

</div>

I think that seems to have stopped it from finishing early, but my animations aren’t running, so unsure if that’s still the same thing affecting it. I’ll investigate further on my side.

\*animations that are meant to run while it’s maintaining focus

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 9:19pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/13 "2025-01-16T21:19:31Z")

</div>

Is it happening in a published experience?

---

<div class="post-metadata">

**Author:** ![flyingpigbaby](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingpigbaby](https://forums.unrealengine.com/u/flyingpigbaby)\
**Post date:** [January 16, 2025, 9:22pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/14 "2025-01-16T21:22:04Z")

</div>

Yep, I mentioned the island code in the ticket, it happens in my current public version and past private versions (that used to work fine).

I’ve just double checked and it definitely fixes it by moving the MaintainFocus to the last block in the race, however as I said before animations seem to not be running while maintaining focus, which wasn’t the case before.

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 9:45pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/15 "2025-01-16T21:45:54Z")

</div>

You cannot play an animation and focus at the same time. The animation is considered as a full body action so it will interrupt the play animation  
It seems that this was not the case before 33.20 and I can’t see why…

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 9:46pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/16 "2025-01-16T21:46:45Z")

</div>

But I don’t see a PlayAnimation in your sample, was that missing?

---

<div class="post-metadata">

**Author:** ![flyingpigbaby](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingpigbaby](https://forums.unrealengine.com/u/flyingpigbaby)\
**Post date:** [January 16, 2025, 9:48pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/17 "2025-01-16T21:48:25Z")

</div>

Just to clarify, are you saying that before 33.20 it **was** possible to play an animation at the sametime, but it shouldn’t have been? (makes sense anyway)

The PlayAnimation wasn’t included yeah, it was part of the logic I had in place of the Sleep(1000.0).

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 9:55pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/18 "2025-01-16T21:55:32Z")

</div>

I need to get an old build to validate this…  
But yes, on our side, we abort the focus when an animation is played.  
If it was possible before 33.20 it was a bug (but I understand that it sounds as a regression)

---

<div class="post-metadata">

**Author:** ![flyingpigbaby](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@flyingpigbaby](https://forums.unrealengine.com/u/flyingpigbaby)\
**Post date:** [January 16, 2025, 9:58pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/19 "2025-01-16T21:58:29Z")

</div>

Oh I might’ve miss lead you there, I mean as in the animation would play while the MaintainFocus was still running, as you say it would abort the focus and play the animation. Previously I can’t remember whether it maintained focus while animating (from what you say that’s not possible anyway). But yeah with the fix you mentioned, it maintains focus, but any animations played won’t play and the focus keeps running.

Thanks so much for helping, I really appreciate the quick responses!

---

<div class="post-metadata">

**Author:** ![FrozenInMTL\_Epic](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/frozeninmtl_epic/32/1181579_2.png) [@FrozenInMTL\_Epic](https://forums.unrealengine.com/u/FrozenInMTL_Epic)\
**Post date:** [January 16, 2025, 10:06pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/20 "2025-01-16T22:06:49Z")

</div>

No problem, but you should be able to play an anim, and it should abort the focus.  
We have a few layers: navigation, stance, upper body, focus, and actions are using one or may layers, and you can only have one action per layer. Focus is focus, play animation is all of them, so they are exclusive (but not focus and navigate)

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [July 14, 2025, 10:49pm UTC](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173/22 "2025-07-14T22:49:20Z")

</div>

This topic was automatically closed after 180 days. New replies are no longer allowed.

[Next page](https://forums.unrealengine.com/t/focus-interface-maintainfocus-now-instantly-completes/2279173.md?page=2)
