using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Fortnite.com/Game } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # This is our "Class Blueprint." # Think of this like a character card in a trading card game. # It defines what stats a player gets when they pick this class. player_class := struct: Health : float Speed : float Name : string # Here are our two choices. # The Bruiser is tough but slow. The Speedster is fast but squishy. BruiserClass : player_class = player_class: Health := 500.0 Speed := 0.5 Name := "The Bruiser" SpeedsterClass : player_class = player_class: Health := 100.0 Speed := 2.0 Name := "The Speedster" # This is the main script that runs when the game starts. # It's like the referee blowing the whistle to start the match. class_selector_logic := class(creative_device): # We need a reference to our Trigger Volume device. # In UEFN, you drag the device into this slot in the editor. @editable TriggerDevice : trigger_device = trigger_device{} # This function runs once when the game starts. # It's like setting up the arena before players jump in. OnBegin() : void = # Connect the trigger device's AgentEntersEvent to our own function. # Think of this as handing the trigger device a walkie-talkie. # When the device speaks, we listen. TriggerDevice.AgentEntersEvent.Subscribe(OnAgentEnterTrigger) Print("Game Started! Choose your class by stepping on the Red Zone.") # This is the magic part. # When a player enters the trigger zone, this function is called. # 'Agent' is the person who stepped on the pad. OnAgentEnterTrigger(Agent : agent) : void = # Cast the agent to a fort_character so we can modify their stats. # note: fort_character gives access to SetMaxHealth / SetHealth in the Fortnite character API. if (FortCharacter := Agent.GetFortCharacter[]): FortCharacter.SetMaxHealth(BruiserClass.Health) FortCharacter.SetHealth(BruiserClass.Health) # Log the class assignment so you can confirm it fired. if (Player := player[Agent]): PlayerName := Player.GetDisplayName() Print("{PlayerName} became {BruiserClass.Name}!")