Hello!
Im making CustomNPC to run to some point and if they see enemy , or hit by enemy, I want to make them Attack enemy.Im using verse because I want them to run to some point.
Even if I use Navigatable.StopNavigation() They dont stop until they reach the point.
I attached trash code to test navigation.
Please tell me if we can stop NPC while they are navigated and running to point.
using { /Fortnite.com/AI }
using { /Fortnite.com/Characters }
using { /Verse.org/Colors }
using { /Verse.org/Random }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
using { /UnrealEngine.com/Temporary/SpatialMath }
using { /Fortnite.com/Devices }
NPCBehavior<public> := class(npc_behavior):
@editable Flag1 : creative_prop = creative_prop{}
@editable Flag2 : creative_prop = creative_prop{}
@editable Button : button_device = button_device{}
var LastFlag : int = 2
var IsNPCAttack : logic = false
OnBegin<override>()<suspends>:void =
Button.InteractedWithEvent.Subscribe(ButtonPushed)
if:
Agent := GetAgent[]
Character := Agent.GetFortCharacter[]
Navigatable := Character.GetNavigatable[]
Focus := Character.GetFocusInterface[]
then:
loop:
Flag1Location := Flag1.GetTransform().Translation
Flag2Location := Flag2.GetTransform().Translation
NavTargetFlag1 := MakeNavigationTarget(Flag1Location)
NavTargetFlag2 := MakeNavigationTarget(Flag2Location)
if(LastFlag = 2):
Print("Going to flag1")
NavResultGoTo := Navigatable.NavigateTo(NavTargetFlag1, ?MovementType:=movement_types.Running)
set LastFlag = 1
if(LastFlag = 1):
Print("Going to flag2")
NavResultGoTo := Navigatable.NavigateTo(NavTargetFlag2, ?MovementType:=movement_types.Running)
Print("Reach")
set LastFlag = 2
if(IsNPCAttack = true):
Navigatable.StopNavigation()
Sleep(5.0)
ButtonPushed(Agent:agent):void=
Print("ButtonPush")
set IsNPCAttack = true
Thank you in advance!