Get custom npc_behavior from spawned NPC

I have created a custom NPC behavior zombie_npc_behavior<public> := class(npc_behavior) but I cannot figure out how to access it from another creative_device when calling GetNPCBehavior

This is my method inside a creative_device that handles spawning the NPC from its spawner:

    # This function runs when a character is spawned from the NPC Spawner
    # because it's an event handler for SpawnedEvent.
    OnCharacterSpawned(SpawnedAgent:agent):void={
        Print("A character just spawned from this device.")

        # When a character spawns, have them focus on the first player in the playspace
        if:
            FortCharacter := SpawnedAgent.GetFortCharacter[]
            FocusInterface := FortCharacter.GetFocusInterface[]
            PlayerToFocus := GetPlayspace().GetPlayers()[0]
            Behavior := SpawnedAgent.GetNPCBehavior[]
        then:
            spawn{FocusInterface.MaintainFocus(PlayerToFocus)}
            #Here I want to call a method inside zombie_npc_behavior, but GetNPCBehavior only returns the base npc_behavior
    }

How can I access its custom behavior?

Hey, did you try:

Behavior := zombie_npc_behavior[SpawnedAgent.GetNPCBehavior[]]

Thanks!

1 Like