Hi, I want to display a different canvas depending on the player’s class. I have already done this to store each player’s class, but if I use the UI component, how can I get the selected class?
var WhichClassPlayer: [player]?int = map{} @editable ClassSelectorUI: class_selector_ui_device = class_selector_ui_device{}
Because the Subscribe of this device gives me only the agent and not the selected class.
So, I can’t use the UI device? Do I have to place each class selector if I want to be aware of the selected class? Because I’ve tried to see if my class device was triggered by the UI, but it doesn’t.
ClassSelectorUI.ClassSelectedEvent.Subscribe(OnClassSelectedUI)
ClassSelector.ClassSwitchedEvent.Subscribe(OnChanged)
ClassSelector.TeamSwitchedEvent.Subscribe(OnChanged)
So I’m getting you’re using the class selector UI device for players to choose a class?
With the OnClassSelectedUI an event is triggered when a player choosing their class (but not which class) and at the same time the class selector ClassSwitchedEvent should trigger. (Also doesn’t transmit player class)
What I think would be easiest is placing a mutator zone for every class and display the corresponding UI for the right agent with the right class.
Something like this should work for you (make sure your mutator zones have the setting enabled on phase to none)
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
using { /UnrealEngine.com/Temporary/Diagnostics }
test := class(creative_device):
@editable MutatorZones : []mutator_zone_device = array{}
@editable ClassSelectorUI : class_selector_ui_device = class_selector_ui_device{}
OnBegin<override>()<suspends>:void=
ClassSelectorUI.ClassSelectedEvent.Subscribe(EnablingMutatorZones)
if (MutatorZone1 := MutatorZones[0]):
MutatorZone1.AgentEntersEvent.Subscribe(Class1UI)
EnablingMutatorZones(Agent:agent):void=
for (MutatorZone : MutatorZones):
MutatorZone.Enable()
Class1UI (Agent:agent):void=
Print ("Displaying Class 1 UI")