The code here doesn’t seem to work. Anyone know why? My custom NPC just stands there when I damage it.
Here’s the Code
on_damaged_behavior := class(npc_behavior):
# This function runs when the NPC is spawned in the world and ready to follow a behavior. OnBegin<override>()<suspends>:void= if: Agent := GetAgent[] FortCharacter := Agent.GetFortCharacter[] then: # Subscribe the character's damaged event to OnDamaged FortCharacter.DamagedEvent().Subscribe(OnDamaged) # When the NPC is damaged, start chasing the character # that instigated the damage OnDamaged(DamageResult:damage_result):void= Instigator := DamageResult.Instigator if: # Get the Agent and the Navigatable interface Agent := GetAgent[] Character := Agent.GetFortCharacter[] Navigatable := Character.GetNavigatable[] # Get the agent that instigated the damage InstigatingAgent := agent[Instigator?] then: # Start navigating to the InstigatingAgent NavigationTarget := MakeNavigationTarget(InstigatingAgent) spawn{Navigatable.NavigateTo(NavigationTarget)}