Your First Project
Build a complete interactive scene from scratch. You'll create a bouncing ball with physics and a rotating platform with custom scripting.
In this tutorial, you'll create a simple physics playground: a ball that bounces on a rotating platform. Along the way, you'll learn core concepts like entities, components, physics, and scripting — the building blocks of every game in Web Engine.
Prerequisites
Make sure you have the Studio running. If not, follow the Quick Start guide first.
Step 1: Create a New Project#
Start by creating a fresh project:
- Open the Studio and go to the Project Hub
- Click New Project
- Name it "Bouncing Ball" and select the Empty template
- Click Create
You'll see an empty scene with just a default camera. Let's add some objects!
Step 2: Create the Ground Platform#
First, we need a surface for our ball to bounce on:
- Right-click in the Hierarchy Panel → 3D Object → Cube
- Rename it to "Ground" by double-clicking the name or pressing F2
- In the Inspector, set the Transform component values:
- Position: (0, -0.5, 0)
- Rotation: (0, 0, 0)
- Scale: (10, 1, 10)
This creates a flat, wide platform centered at the origin. Now let's add physics so the ball can interact with it:
Add Physics to Ground#
- With "Ground" selected, click Add Component at the bottom of the Inspector
- Search for and add RigidBody
- In the RigidBody component:
- Set
typeto Fixed (static, immovable object) - Set
massto 1.0 (doesn't matter for fixed bodies)
- Set
- Add another component: Collider
- In the Collider component:
- Set
typeto Box - Set
sizeto (5, 0.5, 5) — these are half-extents
- Set
Understanding Collider Size
Collider size uses half-extents, not full dimensions. A box with size (5, 0.5, 5) is actually 10×1×10 units in world space, matching our scaled cube perfectly.
Step 3: Create the Ball#
Now let's add a bouncing ball above the platform:
- Right-click in Hierarchy → 3D Object → Sphere
- Rename it to "Ball"
- Set Transform Position: (0, 5, 0) — 5 units above the ground
Add Physics to Ball#
Add physics components to make the ball fall and bounce:
- With Ball selected, add RigidBody component
- In the RigidBody component:
- Set
typeto Dynamic (affected by gravity and forces) - Set
massto 1.0 - Set
restitutionto 0.8 (bounciness - higher = more bounce) - Set
frictionto 0.3
- Set
- Add Collider component
- In the Collider component:
- Set
typeto Sphere - Set
radiusto 0.5
- Set
Let's also give the ball a bright color so it's easy to see:
- In the Inspector, find the Material component
- Click the color swatch next to
albedoColor - Choose a bright color like red, blue, or yellow
Step 4: Test the Physics#
Let's see our ball in action:
- Press Ctrl/Cmd + P or click the Play button (▶) in the toolbar
- Watch the ball fall due to gravity, hit the ground, and bounce!
- It should bounce several times before coming to rest on the platform
- Press Ctrl/Cmd + P again to stop Play Mode
If the ball falls through the ground, double-check your collider settings. Both the Ground and Ball need colliders, and the Ground's RigidBody must be set to Fixed.
Ball Fell Through?
Common issues:
- Ground RigidBody is not set to Fixed
- Collider sizes don't match the visible geometry
- Ball is starting too close to or inside the ground
Step 5: Add a Rotation Script#
Now let's make things interesting by rotating the platform. We'll write a simple JavaScript script to do this:
- Select the "Ground" entity in the Hierarchy
- Click Add Component in the Inspector
- Search for and add Script
- In the Script component, click Create New Script
- Name it "PlatformRotator" and click Create
The script editor will open. Replace the default code with:
/** * PlatformRotator Script * Rotates the entity continuously around the Y axis * * @param {ScriptAPI} api - The script API for this entity */export default (api) => { // Rotation speed in radians per second // 0.5 radians/sec ≈ 28.6 degrees/sec const rotationSpeed = 0.5; /** * Update function - called every frame * @param {number} dt - Delta time in seconds since last frame * @param {number} time - Total elapsed time in seconds */ return (dt, time) => { // Get current rotation const rotation = api.rotation; // Increment Y rotation based on delta time // Multiplying by dt ensures rotation is frame-rate independent rotation.y += rotationSpeed * dt; // Apply the updated rotation back to the entity api.rotation = rotation; };};Save the script with Ctrl/Cmd + S and close the script editor.
Understanding the Script
This script uses the Script API to access the entity's rotation. The return (dt, time) => ... function runs every frame. By multiplying by dt (delta time), we ensure smooth rotation regardless of frame rate.
Step 6: Test the Complete Scene#
Now let's see everything working together:
- Press Ctrl/Cmd + P to enter Play Mode
- The platform rotates slowly around the Y axis
- The ball falls and bounces on the rotating platform
- As the platform tilts, the ball rolls around due to physics!
- Watch the ball's dynamic behavior as it interacts with the rotating surface
Experiment with Values
Try changing these values and see what happens:
rotationSpeedin the script — make it faster or slowerrestitutionon the Ball's RigidBody — make it bouncier (0.9) or less bouncy (0.3)masson the Ball — heavier balls respond differently- Ball's starting height — drop it from higher up!
Step 7: Add Visual Polish#
Let's make the scene look better with lighting and materials:
Add a Directional Light#
- Right-click in Hierarchy → Light → Directional Light
- Set Position: (5, 10, 5)
- Set Rotation: (-45, 45, 0) to angle it down toward the scene
- In the Light component:
- Enable
castShadowsfor realistic shadows - Set
intensityto 1.0 - Set
colorto white or a warm tint
- Enable
Add Environment Sky#
- Right-click in Hierarchy → Create Empty
- Rename it to "Environment"
- Add an Environment component
- In the Environment component:
- Set
presetto Sunset, Studio, or your preferred preset - Or set
backgroundColorto a solid color
- Set
Improve Materials#
Make the platform look more interesting:
- Select the Ground entity
- In the Material component:
- Set
albedoColorto a neutral gray or blue - Set
metalnessto 0.2 - Set
roughnessto 0.7
- Set
Step 8: Add More Balls (Challenge)#
Want to make it more fun? Add multiple balls:
- Select the Ball entity in the Hierarchy
- Press Ctrl/Cmd + D to duplicate it
- Move the duplicate to a different position, e.g., (2, 6, 0)
- Change its color to distinguish it from the first ball
- Repeat to add 3-5 balls at different heights and positions
Enter Play Mode and watch the chaos as multiple balls bounce and roll on the rotating platform!
Step 9: Save Your Project#
- Press Ctrl/Cmd + S to save the scene
- Your project auto-saves to browser storage
- For a backup, use File → Export Project to download a
.webenginefile
What You Learned#
Congratulations! In this tutorial you learned:
- How to create a new project from scratch
- How to add 3D primitives (Cube, Sphere) to your scene
- How to configure physics components (RigidBody, Collider)
- Understanding of dynamic vs fixed rigid bodies
- How to write a custom JavaScript script to control entity behavior
- Using the Script API to modify entity transforms
- How to test your scene in Play Mode
- How to add lighting and environment for visual polish
- How to duplicate entities and build complex scenes
Advanced Challenges#
Ready to take it further? Try these challenges:
- Variable Speed: Modify the script to speed up or slow down over time using
time - Reverse Direction: Make the platform change rotation direction every 5 seconds
- Ball Launcher: Create a script that applies an upward impulse to the ball when you press Space
- Color Change: Change the ball's color each time it bounces
- Obstacle Course: Add walls, ramps, and obstacles to create a complex physics playground
Next Steps#
Scripting Guide
Learn the full Script API and advanced patterns like input handling, raycasting, and events.
Physics Deep Dive
Master rigid bodies, colliders, constraints, and advanced physics features.
Components Reference
Explore all 50+ built-in components and their properties.
Script Examples
Copy-paste scripts for common game mechanics and behaviors.