# NPC Character Definition Verse Behavior 

**URL:** <https://forums.unrealengine.com/t/npc-character-definition-verse-behavior/2520733>\
**Category:** Verse\
**Tags:** npc, unreal-editor-for-fortnite, fortnite-creative, UEFN, question, fortnite\
**Created:** [May 21, 2025, 4:10am UTC](https://forums.unrealengine.com/t/npc-character-definition-verse-behavior/2520733 "2025-05-21T04:10:08Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BoxGodFish](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@BoxGodFish](https://forums.unrealengine.com/u/BoxGodFish)\
**Post date:** [May 21, 2025, 4:10am UTC](https://forums.unrealengine.com/t/npc-character-definition-verse-behavior/2520733/1 "2025-05-21T04:10:08Z")

</div>

using { /Fortnite.com/AI }  
using { /Verse.org/Simulation }  
using { /Fortnite.com/Characters }  
using { /Fortnite.com/Animation/PlayAnimation }  
using { /Verse.org/Assets }  
using { /UnrealEngine.com/Temporary/SpatialMath }  
using { /Fortnite.com/Game }  
using { /UnrealEngine.com/Temporary/UI }  
using { /Verse.org/Colors/NamedColors }  
using { /Fortnite.com/Teams}

# Getting started: [https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/onboarding-guide-to-programming-with-verse-in-unreal-editor-for-fortnite](https://www.epicgames.com/fortnite/en-US/creative/docs/uefn/Verse/onboarding-guide-to-programming-with-verse-in-unreal-editor-for-fortnite)

# A Verse-authored NPC Behavior that can be used within an NPC Character Definition or an NPC Spawner device’s NPC Behavior Script Override.

CustomZombie := class(npc\_behavior):  
BehaviorHelp : CustomZombieHelper = CustomZombieHelper{}

```
var Attack1 : animation_sequence = fosho

NPCDamage : float = 11.0

# This function runs when the NPC is spawned in the world and ready to follow a behavior.
OnBegin< override>()< suspends>:void=
    # TODO: Replace this with your code
    if { 
        NPCAgent := GetAgent[]
        NPCChar := NPCAgent.GetFortCharacter[]
        
        #Allows us to tell npcs to go to different place like the pathfinding service in roblox
        NPCNav := NPCChar.GetNavigatable[]

        #Control where npc is looking
        NPCFocus := NPCChar.GetFocusInterface[]

        #Control the npc's animations
        NPCAnim := NPCChar.GetPlayAnimationController[]
    } then {
        NPCSpawnLocation := NPCChar.GetTransform().Translation

        loop {
            Sleep(0.1)
            #Checks if npc is alive
            if (not NPCChar.IsActive[]) {
                break
            }
            if (NewTarget := BehaviorHelp.FindNearestTargetFromPos[NPCChar], NewAgent := NewTarget.GetAgent[]) {
                spawn{NPCFocus.MaintainFocus(NewAgent)}
                NavTarget := MakeNavigationTarget(NewAgent)
                NPCNav.NavigateTo(NavTarget, ?MovementType := movement_types.Running, ?ReachRadius := 150.0)
                NPCAnim.Play(Attack1)
                Sleep(0.48)

                DistanceDifference := Distance(NPCChar.GetTransform().Translation, NewTarget.GetTransform().Translation)

                if (DistanceDifference < 150.0) {
                    NewTarget.Damage(NPCDamage)
                }
            } 
        }
    }

# This function runs when the NPC is despawned or eliminated from the world.
OnEnd< override>():void=
    # TODO: Replace this with your code
    Print("Goodbye, NPC!")

```

This is my code for my NPC Character Definition, having trouble trying to figure out how I can make the target to be only a players from a specific class/team

---

<div class="post-metadata">

**Author:** ![swaggod](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/swaggod/32/1051181_2.png) [@swaggod](https://forums.unrealengine.com/u/swaggod)\
**Post date:** [May 21, 2025, 5:01pm UTC](https://forums.unrealengine.com/t/npc-character-definition-verse-behavior/2520733/2 "2025-05-21T17:01:07Z")

</div>

The find target function and custom zombie helper isn’t included here so can’t really help much haha, I would recommend using a team settings device and using IsOnTeam.

---

<div class="post-metadata">

**Author:** ![Benjf29](https://d1ap1mz92jnks1.cloudfront.net/user_avatar/forums.unrealengine.com/benjf29/32/1204359_2.png) [@Benjf29](https://forums.unrealengine.com/u/Benjf29)\
**Post date:** [June 4, 2025, 9:24pm UTC](https://forums.unrealengine.com/t/npc-character-definition-verse-behavior/2520733/3 "2025-06-04T21:24:28Z")

</div>

Yes you should use the onTeam to check if player is on it
