Rivals

AR PVP shooter where you battle zombies in real life to earn $RIVAL tokens.

Rivals

Created At

ETHGlobal New York 2025

Winner of

Flow Foundation

Flow - Best Killer App on Flow 3rd place

Flow Foundation

Flow - Flow Builder Pool Prize

Prize Pool

ETHGlobal

ETHGlobal - 🏆 ETHGlobal New York 2025 Finalist

Project Description

Rivals is a revolutionary Augmented Reality (AR) multiplayer shooter that transforms the real world into a competitive gaming arena. This isn't just a mobile game—it's a sophisticated fusion of Unity AR Foundation, blockchain economics, and AI-driven gameplay that creates a persistent, location-based gaming ecosystem where players compete for cryptocurrency rewards.

The project represents the next evolution of mobile gaming, combining the immersive AR experience of apps like Pokémon GO with the competitive intensity of first-person shooters, all powered by Web3 tokenomics that give real monetary value to in-game achievements.

Key Features:

  • Zombies patrol randomly within your detected space
  • They scream when they first spot you (Alert state)
  • They chase aggressively using pathfinding around real furniture/obstacles
  • They attack when within 1.5 meters
  • They react to damage with hit animations
  • Full death sequence with cleanup

Unity AR Game Architecture:

Core AR Foundation Implementation

The Unity application leverages AR Foundation to create a sophisticated augmented reality experience:

  1. Dynamic Environment Mapping
  • ARPlaneManager: Real-time detection of horizontal and vertical surfaces (floors, walls, tables)
  • ARNavMeshBuilder: Automatically generates navigation meshes from detected AR planes, allowing AI enemies to pathfind through your real environment
  • ARFeatheredPlaneMeshVisualizerCompanion: Visualizes detected surfaces with smooth, feathered edges for better user feedback
  • ARRaycastManager: Enables precise interaction with the real world for object placement and shooting mechanics
  1. Advanced AI System The game features a sophisticated 6-state AI system for zombie enemies:

States: Patrol → Alert → Chase → Attack → Hit → Death

ZombieAI Components:

  • ZombieVision: Field-of-view detection (120° cone, 8-12m range) with line-of-sight checking
  • ZombieMovement: NavMesh-based pathfinding that respects real-world obstacles
  • ZombieAttack: Melee combat system with range validation and damage dealing
  • ZombieHealth: Health management with visual feedback and death animations
  • ZombieSpawner: Dynamic enemy spawning system that considers AR plane availability
  1. Shooting & Combat Mechanics
  • ZombieShooter: Screen-center aiming with crosshair targeting
  • Bullet System: Physics-based projectiles with collision detection
  • CrosshairController: Dynamic UI that changes color based on game mode
  • PlayerHealth: Damage feedback with screen flash, health bar, and audio cues
  1. Location-Based Features
  • LocationMonitor: GPS tracking for player movement and trap discovery
  • Real-time location updates sent to server every few seconds
  • Proximity detection for discovering other players' traps
  • Geofencing for trap activation (within ~10 meters)

Blockchain Integration and Smart Contract Architecture

The game uses a custom ERC-20 token contract (RivalsToken.sol) deployed on multiple chains:

Supported Blockchains:

  • Flow Testnet (Chain ID: 545)
  • Chiliz Spicy Testnet (Chain ID: 88882)
  • Local Anvil (for development)

Token Economics ($RIVAL):

// Rewards
killMonster() → +1 RIVAL token per zombie kill

// Penalties  
dieByMonster() → -20% of current balance
dieByTrap() → -20% transferred to trap owner

// Costs
placeTrap() → -1 RIVAL token

Smart Contract Functions:

  1. killMonster(address): Mints 1 RIVAL token when player kills a zombie
  2. dieByMonster(address): Burns 20% of player's tokens when killed by AI
  3. dieByTrap(address, address): Transfers 20% from victim to trap owner
  4. spend(address, uint256)`: Burns tokens for trap placement

Web3 Infrastructure

Authentication & Wallet Management:

  • Privy Provider: Web3 authentication with social login support
  • WalletConnect: Mobile wallet integration
  • Cross-chain support: Automatic chain switching via Wagmi

Real-time Blockchain Integration:

  • Viem: Modern Ethereum client for contract interactions
  • Automatic transaction handling: Server manages all blockchain calls
  • Balance tracking: Real-time token balance updates
  • Transaction receipts: Full on-chain verification

Database & Server Architecture**

API Endpoints:

  1. /api/movement (Location Tracking)
  • Receives GPS coordinates from Unity app
  • Updates player's last_active timestamp
  • Returns nearby traps within discovery radius
  • Fetches real-time token balance from blockchain
  1. /api/kill-monster (Zombie Elimination)
  • Increments player's kill_count in database
  • Triggers killMonster() smart contract call
  • Awards 1 RIVAL token on successful transaction
  1. /api/place-trap (Strategic Placement)
  • Validates player has ≥1 RIVAL token
  • Calls spend() to burn 1 token
  • Stores trap location in PostGIS database
  • Returns trap ID for Unity game object
  1. /api/die (Death Handling)
  • Death by Monster: Burns 20% of player's tokens
  • Death by Trap: Transfers 20% to trap owner
  • Updates game state and statistics

Game Flow & User Experience

Player Onboarding:

  1. Download Unity AR app
  2. Connect Web3 wallet (Privy authentication)
  3. Grant location & camera permissions
  4. AR plane detection** begins automatically
  5. Tutorial: Learn shooting, movement, trap placement

Core Gameplay Loop:

  1. Explore Real Environment: Move around your space as zombies spawn
  2. Combat: Shoot zombies using screen-tap controls with AR crosshair
  3. Earn Tokens: Each kill awards 1 RIVAL token via blockchain transaction
  4. Strategic Placement: Spend tokens to place invisible traps at GPS locations
  5. Competitive PvP: Other players walking near your traps lose 20% of their tokens to you
  6. Risk/Reward: Death means losing 20% of your token balance

Social & Competitive Features:

  • Real-time Leaderboards: Rankings by kills, tokens, survival time
  • Player Profiles: Track individual stats and achievements
  • Trap Networks Create strategic trap placement patterns
  • Location-based Competition: Battle for control of high-traffic areas

Tokenomics & Monetization

Token Utility ($RIVAL):

  • Earning: 1 token per zombie kill
  • Spending: 1 token per trap placement
  • Risk: 20% loss on death (to monster or trap)
  • Reward: 20% gain when your trap kills another player

Economic Incentives:

  • Skill-based Rewards: Better players accumulate more tokens
  • Strategic Depth Trap placement creates passive income streams
  • High Stakes: Death penalty creates tension and careful gameplay
  • Social Competition: Leaderboards drive engagement

Unique Value Propositions

True AR Integration Unlike superficial AR filters, Rivals uses real environment mapping for gameplay. Zombies navigate around your actual furniture, and the game adapts to your physical space.

Genuine Web3 Economics Not just NFT collectibles—real monetary incentives where skill directly translates to cryptocurrency earnings through competitive gameplay.

Location-Based Strategy GPS-integrated trap system creates persistent, location-based gameplay where your strategic decisions affect other players across time and space.

Cross-Chain Accessibility Multi-blockchain deployment ensures players aren't locked into one ecosystem, with seamless chain switching.

Sophisticated AI State-machine driven zombie AI with realistic pathfinding, vision systems, and behavioral complexity that rivals AAA games.

Market Position

Rivals occupies a unique intersection:

  • AR Gaming (PokĂ©mon GO, Harry Potter Wizards Unite)
  • Battle Royale/Shooter (PUBG Mobile, Call of Duty Mobile)
  • Play-to-Earn (Axie Infinity, StepN)
  • Location-based Gaming (Ingress, Geocaching)

It's positioned as the first truly competitive AR shooter with real cryptocurrency rewards, targeting the growing market of Web3 gaming enthusiasts who want skill-based earning opportunities.

This is a groundbreaking project that could define the future of mobile AR gaming by proving that immersive augmented reality experiences can be both technically sophisticated and economically rewarding for players.

How it's Made

Technical Architecture Overview

Rivals represents a complex fusion of Unity AR Foundation, blockchain economics, and real-time geospatial system. Here's how we solved some gnarly technical challenges to create a persistent, location-based AR shooter.

Unity AR Game Engine - The Core Challenge

Dynamic AR NavMesh Generation The Problem: Traditional games pre-bake navigation meshes, but AR environments are completely unknown until runtime. How do you make AI zombies navigate around a user's real furniture?

Our Solution: We built a real-time NavMesh builder that converts AR Foundation plane data into navigable surfaces. When AR Foundation detects a horizontal plane (like a floor), we automatically create a NavMesh surface. When it detects vertical planes (like walls), we create NavMesh obstacles that AI can't walk through.

Technical Innovations:

  • Real-time conversion: AR planes become NavMesh surfaces in milliseconds
  • Performance optimization: Batched rebuilding every 2 seconds instead of per-frame
  • Obstacle carving: Vertical planes automatically become NavMesh obstacles
  • Memory management: Dynamic cleanup when planes are removed/updated

Cross-Platform Input System The Challenge: Handle both mouse (editor) and touch (mobile) seamlessly while preventing conflicts between shooting and mine placement modes.

We created a mode-aware input system that detects both mouse and touch input simultaneously, but only processes it when in the correct mode. This prevents accidentally shooting when trying to place mines, and ensures smooth gameplay across development and mobile platforms.

GPS + AR Coordinate Fusion - The "Indoor GPS" Problem

The Challenge: GPS coordinates are in latitude/longitude, but Unity works in local 3D space. GPS accuracy indoors is terrible (±10-50 meters).

Our Hacky-But-Brilliant Solution: Instead of trying to solve GPS accuracy (impossible), we abandoned absolute positioning and used proximity-based discovery. When the server detects you're within ~10 meters of a trap's GPS coordinates, it tells Unity to spawn the trap "somewhere in front of you" using AR raycasting to find the actual ground.

Why This Works:

  • Completely sidesteps the indoor GPS accuracy problem
  • Uses AR plane detection for accurate ground placement
  • Creates consistent UX regardless of GPS precision
  • Players still get the location-based gameplay without GPS frustration

Blockchain Integration - Zero-Friction Web3

Server-Controlled Wallet Architecture The Challenge: Web3 games typically require users to manage wallets, sign transactions, pay gas fees. Terrible UX.

Our Solution: The server owns the "game wallet" and pays all transaction costs. When a player kills a zombie, Unity sends an API call to our server, which then executes the blockchain transaction to mint tokens. Players never interact with crypto directly - they just see their token balance increase.

Technical Benefits:

  • Zero gas fees for players (server pays)
  • No wallet management required
  • Instant transactions (no waiting for user signatures)
  • Cross-chain abstraction (server handles chain switching)

Multi-Chain Smart Contract Strategy We deployed the same contract across multiple testnets on with Flow and Chiliz using Foundry. Our smart contract is simple but effective - it mints 1 token per zombie kill, burns 20% of tokens when you die to monsters, and transfers 20% between players when traps are triggered.

Partner Technology: Privy provides Web3 authentication, but cleverly, the server holds the "game wallet" that actually executes transactions.

Database & Geospatial Architecture

PostgreSQL earthdistance for Location Logic The Choice: We used PostgreSQL's earthdistance extension instead of PostGIS for geospatial queries.

Why earthdistance over PostGIS:**

  • Lightweight: No need for full PostGIS overhead for simple distance calculations
  • Built-in to PostgreSQL: earthdistance comes with most PostgreSQL installations
  • Perfect for point-to-point distance: Exactly what's needed for trap proximity detection
  • Earth-curvature aware: Accurate distance calculations using the cube extension

The server calculates distances between player GPS coordinates and all existing traps using earthdistance functions, returning nearby traps to the Unity client for spawning.

Unity-to-Server Communication

The Challenge: Mobile games need robust networking, but Unity's networking is overkill for simple API calls.

Our Streamlined Solution: Direct HTTP API calls using Unity's UnityWebRequest. We have four main endpoints:

  1. Movement API: Receives GPS coordinates, returns nearby traps and token balance
  2. Kill Monster API: Increments kill count, triggers blockchain token minting
  3. Place Trap API: Validates token balance, burns tokens, stores GPS location
  4. Die API: Handles death penalties (burn tokens or transfer to trap owner)

AI System Architecture

We implemented a sophisticated 6-state AI system for zombie enemies: Patrol → Alert → Chase → Attack → Hit → Death.

ZombieVision Component: Handles field-of-view detection with a 120° cone and 8-12 meter range, plus line-of-sight checking that respects AR plane obstacles.

ZombieMovement Integration: Uses the dynamically-built NavMesh to pathfind around real-world furniture and obstacles detected by AR Foundation.

Smart State Management: Zombies patrol randomly within detected space, scream when they first spot you, chase aggressively using pathfinding, and attack when within 1.5 meters.

Performance Optimizations & Notable Hacks

The GPS Indoor Hack Instead of trying to solve GPS accuracy indoors (impossible), we gave up on absolute positioning and used proximity-based discovery. This turned a technical limitation into a feature.

The Blockchain Gas Hack Instead of making players pay gas fees (terrible UX), the server owns a wallet and pays all transaction costs. Players never touch crypto directly but still get real Web3 ownership.

The Cross-Platform Input Hack Instead of using Unity's complex Input Actions system, we detect both mouse and touch simultaneously in every Update() and let the first one win. Simple but bulletproof.

The NavMesh Dynamic Building Hack Instead of trying to build perfect NavMesh from AR data, we use "good enough" box colliders that represent detected planes and let Unity's NavMesh system handle the pathfinding details.

Trap Spawning Optimization We prevent duplicate trap spawning with smart caching - each trap ID is tracked in a dictionary to ensure it only spawns once, even if the GPS proximity detection triggers multiple times.

AR Plane Performance Optimization We batch process planes (max 5 per frame) and only rebuild NavMesh every 2 seconds instead of every frame, preventing performance drops during intensive AR scanning.

Technology Stack Choices & Rationale**

Unity AR Foundation Next.js + TypeScript PostgreSQL + earthdistance Foundry Viem + Wagmi

Most Notable Technical Achievements**

  1. Solved the "Indoor GPS" problem by abandoning absolute positioning for proximity-based discovery
  2. Created seamless Web3 UX by having server pay all gas fees while preserving token ownership
  3. Built dynamic AI navigation that works in any real-world environment using AR plane conversion
  4. Achieved cross-platform compatibility with unified input handling for mobile and desktop
  5. Implemented real-time geospatial gameplay using lightweight PostgreSQL extensions instead of complex GIS systems

The most impressive hack is probably how we turned GPS inaccuracy from a limitation into a feature - instead of fighting physics, we embraced "approximate location" and made it part of the game design. Players get location-based gameplay without the frustration of precise positioning requirements.

This project demonstrates that with clever architecture choices and willingness to work around technical limitations rather than against them, you can create sophisticated AR experiences that feel magical to users while being surprisingly practical to build.

background image mobile

Join the mailing list

Get the latest news and updates