How do i access GetPlayspace() from Npc_Behavior

I wanna grab all players from inside the npc behavior but i cant access GetPlayspace() from Fort_Character it has to be accessed from a creative device

1 Like

you should still be able to link creative devices. I would try making a creative device that has as many events/playspace functions as you need and then linking it and calling functions to update variables in your npc script

You could have something like this in your creative device

Return_All_Players():[]player=
    AllPlayers := GetPlayspace().GetPlayers()
    return AllPlayers

and then in your NPC Behavior just have a player array variable and set it by calling this fuction any time you need to reference it

if you don’t need the player array from getplayspace you could also set up you’re own events to signal when regular events happen and pass params into them.

(Still in your creative device)

Player_Ref := struct:
    _Player:player

Custom_P_Added_Event : event(Player_Ref) = event(Player_Ref){}

Signal_Custom_Event()<suspends>:void=
    loop:
        Player_Added := GetPlayspace().PlayerAddedEvent.Await()
        Custom_P_Added_Event.Signal(Player_Ref{_Player := Player_Added})

#listen for this event in your NPC Behavior 
2 Likes

do i actually need the device in my map or just having the class be enough?

haven’t really messed with NPC_Behavior yet but feel like just having an @editable class reference and linking the device should be fine.

If you can like a mutator for example i don’t see why you couldn’t link a device you made. They’re both inheriting from the same parent class.

Try creative_device{}.GetPlayspace()

2 Likes