Build a Target Practice Mini-Game with Verse
Unverified — this example may not compile as-is.
The Verse code below did not pass our automated compile check, so it isn't marked verified and is hidden from the guide listing. The explanation may still be useful, but treat the code as a draft and adapt it before use.
Build a Target Practice Mini-Game with Verse
Do you want to build a game where players must aim carefully to win? You can make a "target practice" island using the Skilled Interaction device. This device checks if a player hits a specific spot at the right time. It is like playing darts or archery, but you build the rules with code!
What You'll Learn
- How to use the Skilled Interaction device for aiming games.
- How to set Good, Perfect, and Bad zones for targets.
- How to use Verse to give rewards when players hit the target.
- How to connect devices using the Scene Graph.
How It Works
Imagine you are playing archery. You have a bow and arrow. You want to hit the bullseye. If you hit the center, you get a lot of points. If you hit the edge, you get a few points. If you miss, you get nothing.
The Skilled Interaction device works the same way. It is a special box in your game world. When a player interacts with it (like pressing a button or shooting), the device checks where they aimed.
We can set up three zones:
- Perfect Zone: The very center. This gives the best reward.
- Good Zone: The outer ring. This gives a small reward.
- Bad Zone: The area outside the target. This gives no reward or a penalty.
In Fortnite Creative, we use Verse to tell the game what to do. Verse is the language we use to write these rules. Think of Verse as a recipe. The ingredients are the devices. The steps are the code.
We will build a simple target. When a player hits the "Perfect Zone," a prize pops up. This is a great way to practice your coding skills!
Let's Build It
First, place your devices in the editor.
- Place a Skilled Interaction device. Name it
TargetDevice. - Place a Prop Mover or Item Granter for the prize. Name it
PrizeBox. - Set the Skilled Interaction settings. Choose "Quick Press" for simplicity. Set the "Perfect Zone" to be a small circle in the middle.
Now, let's write the Verse code. This code listens for the player's aim. It checks if they hit the perfect spot. If they do, it activates the prize.
Copy this code into a new Verse file in your island.
# This is a comment. It explains the code to humans.
# We are making a script for our Target Device.
using { /Fortnite.com/Devices }
using { /Verse.org/Simulation }
# This is our main script. It acts as a creative_device
# and holds references to the two devices we placed in the editor.
target_practice_script := class(creative_device):
# These are the two devices we placed in the editor.
# Assign them in the Details panel in UEFN.
@editable
TargetDevice : skilled_interaction_device = skilled_interaction_device{}
@editable
PrizeBox : item_granter_device = item_granter_device{}
# This function runs when the game starts.
OnBegin<override>()<suspends> : void =
# We wait for the player to interact with the target.
# 'InteractedWithPerfectEvent' fires when someone hits the Perfect zone.
# 'InteractedWithGoodEvent' fires when someone hits the Good zone.
loop:
# Block here until the Perfect zone is triggered.
Agent := TargetDevice.InteractedWithPerfectEvent.Await()
# If it was a perfect hit, we give the prize!
PrizeBox.GrantItem(Agent)
Walkthrough
target_practice_script := class(creative_device): This line creates a new script. It extendscreative_device, which is the real base class for all UEFN island scripts. Think of it as a brain attached to the island.@editable: This tag makes a field visible in the UEFN Details panel so you can drag your placed devices into the slots without hardcoding names.OnBegin: This code runs once when the island starts. It sets up the listening loop.loop: ... TargetDevice.InteractedWithPerfectEvent.Await(): This is a suspending loop. It waits forever for a player to hit the Perfect zone. It does not stop until the game ends. Theskilled_interaction_deviceexposesInteractedWithPerfectEventandInteractedWithGoodEventas the real named events for each zone.PrizeBox.GrantItem(Agent): This is the fun part! It triggers the prize for the specific player (Agent) who hit the bullseye. You can swapitem_granter_devicefor other devices, like ascore_manager_device, to change the score instead.
Try It Yourself
You have built the basic target. Now, let's make it harder!
Challenge: Add a "Good" zone reward.
- Hint: The loop above only listens to
InteractedWithPerfectEvent. You can add a second branch that listens toInteractedWithGoodEventat the same time. - Create a second prize box for the "Good" zone.
- Update the code so that if the aim is
Good, it activates the second box.
Can you make the code check for three different zones?
Recap
You learned how to use the Skilled Interaction device to make a target game. You used Verse to listen for player actions. You checked the aim quality to decide what reward to give. This is a great start for making mini-games on your island!
References
- https://dev.epicgames.com/documentation/en-us/fortnite/skilled-interaction-device-design-examples
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/skilled-interaction-device-design-examples
- https://dev.epicgames.com/documentation/en-us/fortnite/using-skilled-interaction-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-skilled-interaction-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite/34-10-fortnite-ecosystem-updates-and-release-notes
Get the complete code — free
You've read the full walkthrough. The complete, copy-paste-ready Verse solution is free for members — sign in to unlock it.
Free with your BrainDead.TV / BrainDeadGuild Discord account. The walkthrough above is always free.
Verse source files
- 01-device.verse · device
- 02-device.verse · device
Turn this into a guided course
Add skilled-interaction-device-design-examples to your free study plan — we'll suggest related pages and stitch the lot into one compile-checked, self-guided lesson with worked examples and quizzes.
References
Original tutorial generated by Verse Island from the Verse/UEFN knowledge base, with references to the Epic Games sources above. Code is validated against the knowledge base.