# This is the main script for our race checkpoint. # It uses the Save Point device to remember the player. using { /Fortnite.com/Devices } using { /Fortnite.com/Characters } using { /Verse.org/Simulation } using { /UnrealEngine.com/Temporary/Diagnostics } # We create a new device type called "RaceCheckpoint". # This is like a blueprint for our checkpoint. race_checkpoint := class(creative_device): # This is the Save Point device we placed in the world. # It is a reference to the actual object on the map. # Wire this in the UEFN Details panel — do not set it here. @editable SavePoint : checkpoint_device = checkpoint_device{} # This is the Timer device we placed in the world. # It tracks how long the race takes. # Wire this in the UEFN Details panel — do not set it here. @editable Timer : timer_device = timer_device{} # This function runs when the game starts. OnBegin() : void = # Subscribe to the checkpoint device's activation event. # CheckpointDevice fires ActivatedEvent when a player touches it. SavePoint.CheckpointActivatedEvent.Subscribe(OnPlayerReachedCheckpoint) # Start the race timer as soon as the game begins. Timer.Start() # This function runs when a player enters the Save Point. # The checkpoint_device passes the agent (player) who activated it. OnPlayerReachedCheckpoint(Agent : agent) : void = # Pause the timer so we can read a stable value. Timer.Stop() # Cast agent to fort_character so we can use character helpers. # note: fort_character is the real Verse type for a Fortnite player character. if (Character := Agent.GetFortCharacter[]): # Show a heads-up message by printing to the log. # note: player.ShowMessage() does not exist in Verse; # HUD messages are driven by hud_message_device wired in the editor. Print("Checkpoint Saved! Keep going!") # Resume the timer so the race continues from where it paused. Timer.Start()