Chop It Down! Building a Falling Tree Trap
Chop It Down! Building a Falling Tree Trap
Have you ever wanted to build a trap that feels real? Imagine a giant tree that players can chop down. When it falls, it crashes through walls and knocks enemies over. It is like a giant domino effect. You will make this happen with a Physics Tree.
What You'll Learn
- What a Physics Tree device is.
- How to place it in your island.
- How to make it fall and hit things.
- How to use Verse to check if it fell.
How It Works
Think of a normal tree in Fortnite. It looks nice. But if you shoot it, it just vanishes. Poof! Gone. It does not leave a mess.
A Physics Tree is different. It is a heavy, solid object. It has a trunk and branches. When you damage it enough, it does not disappear. Instead, it becomes a log. This log obeys physics.
Physics is the rulebook for how things move in the real world. Gravity pulls things down. Momentum pushes things forward. When the tree falls, it acts like a real log. It can smash through wooden walls. It can knock players away. It is a hazard.
You can control how much damage it does. You can also make it fall automatically. This lets you build puzzles or traps.
Let's Build It
We will build a simple trap. We will place a tree. We will use Verse to make it fall when a player steps on a button. Then, we will show a message when it hits the ground.
First, open UEFN. Go to the Devices menu. Search for "Physics Tree". Drag one onto your island. Place it high up on a cliff. This gives it room to fall.
Next, we need Verse code. Verse is the language we use to talk to devices. It tells the tree when to fall.
Copy this code into a new Verse file. Make sure you save it as a script for your island.
using { /Fortnite.com/Devices }
using { /Verse.org/Sim }
# This is our main script.
# It watches the tree and the button.
class MyTreeScript is WorldDevice():
# This is the tree device.
# We will link it in the editor.
TreeDevice: physics_tree_device = physics_tree_device()
# This is the button player steps on.
# We will link it in the editor too.
TriggerButton: button_device = button_device()
# This runs when the game starts.
OnBegin<override>()<suspends>: void =
# We listen for when the button is pressed.
TriggerButton.PressedEvent.Subscribe(SimulateFall)
# This function makes the tree fall.
SimulateFall(): void =
# We tell the tree to start falling.
# It will now obey gravity.
TreeDevice.Fall()
# We wait a little bit.
# This gives time for the tree to move.
Wait(2.0)
# Now we check if the tree is on the ground.
# If it is, we print a message.
if TreeDevice.IsOnGround():
Print("The tree has crashed down!")
Let’s look at this code line by line.
The first line says using { /Fortnite.com/Devices }. This is important. It tells Verse, "I want to use devices from Fortnite." Without this, Verse does not know what a physics_tree_device is.
Next, we define MyTreeScript. This is a Class. A class is like a blueprint. It describes what our script can do. It is like a recipe card for a cake.
Inside the class, we have TreeDevice. This is a Variable. A variable is a box that holds data. Here, the box holds the tree. We must link this box to the actual tree in the editor later.
We also have TriggerButton. This is another variable. It holds the button device.
The OnBegin function runs when the game starts. It sets up the connection. It says, "When the button is pressed, run the SimulateFall function."
The SimulateFall function is the action. It calls TreeDevice.Fall(). This tells the tree to drop. It uses gravity. Then we wait two seconds. Finally, we check if the tree hit the ground. If it did, we print a message.
To make this work in UEFN:
- Place your Physics Tree.
- Place a Button Device nearby.
- Add a Verse Script device to your island.
- Link your
TreeDevicevariable to the Physics Tree. - Link your
TriggerButtonvariable to the Button. - Play your island. Press the button. Watch the tree crash!
Try It Yourself
You made the tree fall. Now, let’s make it smarter.
Challenge: Add a second button. Make the tree fall only if the player presses the first button, then waits one second, then presses the second button.
Hint: You can use a Timer Device. When the first button is pressed, start the timer. If the second button is pressed before the timer ends, do nothing. If the timer finishes, then allow the second button to trigger the fall.
Recap
You learned about Physics Trees. They are heavy logs that fall with gravity. They can damage structures and players. You used Verse to control them. You linked devices to variables. You made the tree fall on command. Great job!
References
- https://dev.epicgames.com/documentation/en-us/fortnite/using-physics-tree-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-physics-tree-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/en-us/fortnite-creative/using-devices-in-fortnite-creative
- https://dev.epicgames.com/documentation/fortnite/verse-api/fortnitedotcom/devices/physics_tree_device
- https://dev.epicgames.com/documentation/en-us/fortnite/down-but-not-out-device-design-examples-in-fortnite-creative
Verse source files
- 01-fragment.verse · fragment
Turn this into a guided course
Add using-physics-tree-devices-in-fortnite-creative 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.