Wizard’s Duel AR (Prototype): Cross-Platform Multiplayer Augmented Reality Game using Google Cloud Anchors and GameSparks

Kenneth Ng
Jul 9, 2018 · 7 min read
Real gameplay footage, shot on iPhone X, iPhone 6s Plus, and Google Pixel 2 XL.

It’s the age of augmented reality (AR).

AR is yet to make a major breakthrough, but there has been a slew of exciting advancements in preparation for a future where AR glasses will sit on everybody’s faces.

The Challenge

Previously, AR experiences were reserved for the individual initializing the AR session on his or her phone.

1. A common frame of reference

When a person starts an AR session on their phone, the camera analyzes the environment frame-by-frame to develop a visual understanding of the real world, looking for distinct features like lines and corners. Each person’s camera acts on their own, and without a way for the phone to share what it sees with other phones, it wouldn’t be possible for any two users to place and move virtual content on top of the real world using the same coordinate system.

2. Synchronized content between players

If I place a virtual dog on the ground whining for food, it’s expected that everybody looking at my virtual dog sees the same thing. Virtual content needs to be synchronized across all viewers, no matter who initiates it. Otherwise, it creates a blatant disconnect from reality.

3. Physical and interactive

When you superimpose virtual content on top of reality, users expect to be able to engage with the virtual content just as you would with real-world objects. AR experiences should therefore encourage its users to engage with the virtual content as much as possible. For example, conventional user interface elements on the smartphone screen, such as buttons, scrolling, and sliders, should be avoided unless they’re augmented onto the real-world for the user to interact with.

The Concept

Almost everybody loves fantasy, right? How good would it feel to be able to wield a fireball in your hand and blast somebody with it? Or to conjure a lightning strike by drawing symbols on the floor?


The Technology

Google Cloud Anchors

During I/O ‘18, Google presented a crafty solution called Google Cloud Anchors, which allows users to host an anchor to the cloud that others can then resolve. What this means is that users can share a spatial mapping of their surrounding environment with each other, and Google helps put together a common frame of reference via an anchor—the cloud anchor.

Share AR Experiences with Cloud Anchors

GameSparks real-time services

Powered by AWS, GameSparks is a full-on backend-as-a service targeted specifically for online multiplayer games. They provide low-latency multiplayer networking solutions that are perfect for real-time synchronization of virtual content between players.

The Game

Wizard’s Duel AR is a cross-platform, multiplayer AR brawler for players with ARKit- and ARCore-supported smartphones. Two or more players engage in real-time combat by blasting each other with magic and defending themselves with shields. There are no win conditions or rules. Players can host new duels and join or spectate existing duels.

Camera-tracking wands

The wand is a visual representation of the position and rotation of each player’s smartphone shared live with all other players. Mobile AR is not without its faults, so how far the wand is from the actual player’s phone gives you an idea of the discrepancy that happens due to drifting.

Physics-based projectiles

The magical projectiles that fly from each player’s wand are physics-based and set at a speed that allows opponents to dodge and re-position themselves. This encourages players to be physically active during the game.


I introduced shields not only as a defensive mechanic but also as a cooperative mechanic that encourages players to physically interact with each other. For example, you could have a version of this game with teams where the win condition is to reduce your opponent’s health. Low-health players could take cover behind the shields of their teammates as they recover.

Invisible colliders

As fun it is to blast your opponents, it wouldn’t be very satisfying if the projectiles kept flying through their bodies.

Drop in & drop out

Lastly, the game is configured to allow players to jump in and out of the game and even spectate if they want to. AR experiences are extensions of the real world, so any public activity should be open to bystanders.

Game Flow

  1. Players log-in with a username and password. Players can input any random username and password to be authenticated.
  2. One player selects the option to Host a duel. An AR session is initiated and the player’s camera scans the environment. Once a plane has been created, the hosting player can tap on the screen to place a cloud anchor on the plane and submit it to the Google servers. Once the anchor is successfully processed, other players can join this AR session by resolving the cloud anchor. The game does not start until at least one other player has entered the duel.
  3. All other players who are joining the duel select the option to Join. The players must input the room number of the duel and the IP address of the host player — this information is available in the top right corner of the host player’s screen. Once the required information has been inputted, the camera scans the environment to resolve the cloud anchor. Once the anchor has been successfully resolved, the player joins the AR session created by the host player and the game starts.
  4. When the game starts, all players in the AR session can immediately begin dueling.


Tap on the screen to fire projectiles. Hold your finger on the screen to raise the shield.


Playing AR games on mobile at a 1:1 scale with the real world is quite awkward. Trying to dodge a projectile that you can only see through your phone screen creates an immediate disconnect from reality. That’s why most mobile AR applications either scale the virtual content down to fit the space in front of you or are planted down at a set location that doesn’t require you to look around.

  • Draw symbols on the floor below an opponent to cast spells. Since this uses raycasting, players can feel their touch actions on the phone screen be transposed directly onto the real world.
  • Be creative with projectiles. Your eyes have no depth perception on the phone screen because everything is scaled down. You have no way of gauging where and how far you’re shooting — try it yourself by turning off the cross-hairs in a first-person shooter game. However, there are ways to address these challenges. You could try, for example, line renderers instead of particles for the projectile trail because the line renderer visibly reduces in size the farther it travels. You could also have a more concrete object, like a ball or rocket.

Thanks for reading!

Kenneth L. Ng

AR/VR Developer at Alibaba. Welcome to my portfolio.


25 claps
Kenneth Ng

Written by

AR/VR Developer at Alibaba

Kenneth L. Ng

AR/VR Developer at Alibaba. Welcome to my portfolio.