Custom NPC Behavior: Teaching a Villager to Flee
verse-library
# OnBegin runs when the NPC enters the simulation. Wire up its damaged event.
OnBegin<override>()<suspends> : void =
if:
Agent := GetAgent[]
Character := Agent.GetFortCharacter[]
then:
Character.DamagedEvent().Subscribe(OnDamaged)
Print("Villager is on patrol duty... nervously.")
# When hit, run directly away from the instigator and stare them down.
OnDamaged(Result : damage_result) : void =
if:
Agent := GetAgent[]