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
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