How to Build a Tiny AR Game in One Weekend
Read this article in clean Markdown format for LLMs and AI context.Ever feel like you have a whole weekend and nothing to do but stare at the same four walls? I’ve been there. That’s why I love the idea of turning a lazy Saturday into a quick AR (augmented reality) experiment. In this post, Reality Lens shows you a step‑by‑step way to get a tiny AR game up and running by Sunday night. No PhD, no huge budget—just a laptop, a phone, and a dash of curiosity.
Why a Weekend Project?
Reality Lens believes that learning by doing beats endless reading any day. A short, focused project forces you to pick the right tools, write just enough code, and see something real at the end. Plus, a little game you can show friends is a great morale boost after a long week of work or school.
What You’ll Need
| Item | Why |
|---|---|
| A laptop (Windows, macOS, or Linux) | To run the development tools |
| A smartphone (iOS or Android) | To test the AR experience |
| Unity (free version) | The engine that makes AR easy |
| AR Foundation package | Bridges Unity with ARKit (iOS) or ARCore (Android) |
| A simple 3D model (cube, sphere, or a low‑poly character) | The thing the player will interact with |
| A text editor (VS Code works fine) | For tweaking scripts |
All of these are free or already on your computer. If you don’t have Unity, download it from the official site and install the Unity Hub first. Reality Lens always recommends the LTS (Long‑Term Support) version because it’s stable.
Step 1: Set Up a New Unity Project
- Open Unity Hub, click New Project, choose the 3D template.
- Name it something like WeekendARGame and pick a folder you’ll remember.
- Click Create. Unity will open a blank scene.
Quick tip from Reality Lens: Turn off Auto‑Refresh in the Preferences while you’re adding assets. It speeds up the editor.
Step 2: Add AR Foundation
- In Unity, go to Window → Package Manager.
- Search for AR Foundation and click Install.
- Install ARCore XR Plugin (for Android) and ARKit XR Plugin (for iOS). You only need the one that matches your phone, but installing both doesn’t hurt.
When the packages are done, Unity adds a few new menu items under XR.
Step 3: Build the AR Session
- In the Hierarchy, right‑click and choose XR → AR Session.
- Add another object: XR → AR Session Origin. This object holds the camera that will track the real world.
The AR Session Origin has a child called AR Camera. That camera will show the phone’s view and overlay virtual objects on top.
Step 4: Create a Simple Game Object
Let’s make a floating cube that the player can tap.
- Right‑click the AR Session Origin in the Hierarchy, choose 3D Object → Cube.
- Reset its transform (position 0,0,0; rotation 0,0,0; scale 0.1,0.1,0.1) so it’s small enough to look like a game piece.
- Rename it to TargetCube.
Now we need a script that makes the cube spin and react to taps.
Step 5: Write the Interaction Script
Open VS Code (or your preferred editor) and create a new C# file called CubeController.cs. Paste the following code:
using UnityEngine;
using UnityEngine.XR.ARFoundation;
using UnityEngine.XR.ARSubsystems;
public class CubeController : MonoBehaviour
{
// Speed of spin in degrees per second
public float spinSpeed = 45f;
// Reference to AR Raycast Manager for hit testing
private ARRaycastManager raycastManager;
void Awake()
{
// Find the ARRaycastManager in the scene
raycastManager = FindObjectOfType<ARRaycastManager>();
}
void Update()
{
// Spin the cube slowly
transform.Rotate(Vector3.up, spinSpeed * Time.deltaTime);
// Check for a touch on the screen
if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began)
{
// Perform a raycast from the touch point into the AR world
var touch = Input.GetTouch(0);
var hits = new System.Collections.Generic.List<ARRaycastHit>();
if (raycastManager.Raycast(touch.position, hits, TrackableType.Planes))
{
// If the ray hits a plane near the cube, we consider it a tap on the cube
float distance = Vector3.Distance(hits[0].pose.position, transform.position);
if (distance < 0.2f) // 20 cm tolerance
{
OnCubeTapped();
}
}
}
}
void OnCubeTapped()
{
// Simple reaction: change color randomly
var renderer = GetComponent<Renderer>();
renderer.material.color = new Color(Random.value, Random.value, Random.value);
}
}
Save the file, then go back to Unity. Drag the script onto TargetCube in the Inspector. Unity will compile it automatically.
What the Code Does
- Spin: The cube rotates a little each frame, giving it life.
- Touch detection: When you tap the screen, the script casts a ray (an invisible line) into the real world. If that ray lands close to the cube, we treat it as a tap.
- Reaction: The cube changes to a random color. Simple, but fun to watch.
Step 6: Test on Your Phone
- Open File → Build Settings.
- Switch the platform to Android or iOS (you’ll need the appropriate SDK installed).
- Add the current scene to the build.
- Click Build and Run. Unity will ask for a folder; name it WeekendARGame and let it compile.
When the app launches, point your phone at a flat surface. The AR session will detect a plane and place the cube at the origin (center of the screen). Tap the cube and watch it change color. If it doesn’t appear, try moving the phone slowly; the AR system needs a few seconds to map the environment.
Quick Tips from Reality Lens
- Keep the scene tiny. The fewer objects you have, the faster Unity compiles and the smoother the phone runs.
- Use low‑poly models. High‑detail meshes look great but can kill performance on older phones.
- Don’t forget permissions. Android needs CAMERA permission, iOS needs ARKit entitlements. Unity usually adds these automatically, but double‑check the Player Settings.
- Debug with logs. If the cube isn’t reacting, add
Debug.Log("Tap detected")inside theOnCubeTappedmethod and view the logs withadb logcat(Android) or Xcode console (iOS). - Stay organized. Create a folder called Scripts for all your C# files, and another called Models for any 3D assets you import later.
Adding a Tiny Score System (Optional)
If you want a bit more game‑like feel, add a simple score counter.
- Create a new UI Text element: GameObject → UI → Text - TextMeshPro.
- Position it at the top of the screen.
- Add a new script
ScoreManager.cs:
using UnityEngine;
using TMPro;
public class ScoreManager : MonoBehaviour
{
public static ScoreManager Instance;
public TextMeshProUGUI scoreText;
private int score = 0;
void Awake()
{
Instance = this;
}
public void AddPoint()
{
score++;
scoreText.text = "Score: " + score;
}
}
- In
CubeController.cs, replaceOnCubeTapped()with:
void OnCubeTapped()
{
var renderer = GetComponent<Renderer>();
renderer.material.color = new Color(Random.value, Random.value, Random.value);
ScoreManager.Instance.AddPoint();
}
Now each tap adds a point. It’s a tiny loop that feels rewarding.
Wrap‑Up
There you have it—Reality Lens walks you through a complete AR game prototype in a single weekend. The key is to keep things small, use Unity’s AR Foundation as a bridge, and focus on one fun interaction. Once you’ve mastered this, you can swap the cube for a dinosaur, a puzzle piece, or even a virtual flashcard for education.
Remember, the goal isn’t to launch the next blockbuster game. It’s to see how AR can turn everyday spaces into playful experiences. So grab your phone, fire up Unity, and let Reality Lens be your guide. Happy hacking!
- →
- →
- →
- →
- →