Screen Bounds Sample Project
StudioThis is a sample project that shows how to create and track screen bounds on a 2.5D project.
This is a sample project that shows how to create and track screen bounds on a 2.5D project.
Screen Bounds Platformer Starter
Welcome! This is a simple but powerful starting point for building screen-bound 2.5D platformers or arcade-style games using Niantic Studio’s ECS framework. This setup gives you total control over how your game world fits inside the camera view across any device.
It includes two custom components
- A screen bounds utility that projects the camera view into world space
- A responsive player controller with screen wrap
Perfect for jumpers, scrollers, or any AR game that needs pixel-perfect layout.
What's Included
screenBoundsController
This component calculates where the edges of the screen land in world space by projecting the camera's view frustum onto a plane. It works along any axis (x, y, or z) and emits a Camera Bounds Ready event with the calculated values.
Features
- Projects camera bounds onto a custom axis-aligned plane
- Emits Camera Bounds Ready with world min and max values
- Optionally clamps the bounds to a defined range
- Debug draw to visualize the four screen corners in 3D space
- Can auto-adjust the scene's offset to match a target width or height, such as fitting the level perfectly on screen
playerController
This component listens for button input using UI_PRESSED and UI_RELEASED and moves a player entity left or right along the X-axis. It wraps the player from one side of the screen to the other using the values from screenBoundsController.
Features
- Horizontal movement based on button press
- Smooth, frame-rate-independent motion
- Automatic wrap-around when leaving screen bounds
- Waits for Camera Bounds Ready before activating movement
Two Game Spaces
One game scene uses the Adjust World Offset toggle and the other doesn't. when jumping between the two spaces reload the preview and make sure the active space's camera is the active camera.
Example Use Cases
Screen Wrap (Doodle Jump style)
Use boundaries to detect when the player leaves the screen and teleport them to the opposite side
Parallax Layers
Position background elements to match the screen width at any distance using rawBoundaries
Dynamic Camera Control
Move the camera only when your player enters the outer 10 to 15 percent of the screen using boundaries to trigger camera pans
Debugging
Enable debugDraw true on the screen bounds component to see markers
- 🔴 Top left
- 🟢 Top right
- 🔵 Bottom left
- 🟡 Bottom right
These help confirm the bounds are projecting correctly onto your scene and that objects are aligned properly
Notes
- Only the first camera found in the scene is used. You can modify the logic to use a specific one if needed
- You must wait for the Camera Bounds Ready event before relying on the bounds data
- Projection is automatically skipped if the plane is behind the camera
Setup Instructions
- Clone this project
- Register both components in your Niantic Studio project
- Add screenBoundsController to any entity to calculate bounds
- Add playerController to your player and assign the left and right buttons in the editor
- Optional - Listen for the Camera Bounds Ready event elsewhere in your systems
License
This project is open-source and licensed under the MIT License. You are free to use, remix, or build on top of it however you like
Need Help
If you're trying this out and get stuck, or if you just want to say hi, feel free to reach out
I’m happy to help however I can
dclnjohnson@gmail.com
– Declan
Other Work by DCLN