Multiplayer augmented reality game powered by PubNub.
Augmented reality is a fresh new layer for gaming that promises new experiences for users and more revenue for game studios. However, AR brings new challenges to traditional game design when you start to build multi-user games and need to sync content between them. Even in single player games where there's no content to sync, there's a significant demand from users to add social experiences like chat and leaderboards.
The objective of Cube Fight is to take cubes from other players by using the Magic Leap Eye Gaze feature to select a cube and the trigger on the controller to take it. PubNub will handle transmission of messages regarding the ownership state of each cube.
Learn more about how to build your own multiplayer AR game with Magic Leap and PubNub from the tutorial.
This is Part three of my Magic Leap series. Check out the other projects/posts Getting Started with Magic Leap and PubNub and Controlling Internet-connected Devices with Magic Leap Hand Gestures.
Developers have been building multiplayer games and other multi-user experiences with PubNub for years, and PubNub definitely sees AR as next on the horizon. PubNub is a natural fit in the AR world and their technology can power the realtime interaction between AR headsets or physical objects in the same location, or even across the Earth.
For instance, when a Magic Leap user throws a ball in the virtual world, that motion is synchronized in realtime across every other connected user. Or if a user uses a hand gesture to turn on a light, PubNub is sending the message to that light to turn on. Multi-user experiences, or the relationship between the AR headset and the physical world around us, is where PubNub is required and excels.
This game uses Magic Leap Eye Gaze to select game objects (the cubes) and the trigger on the controller to take them. Additionally, there's an eye position indicator to aid the user in knowing where the device thinks they are looking.
There are three states/colors each cube can be in:
- Not Focused (red) - The user is not looking directly at the cube, has not taken the cube, and another player owns the cube.
- Focused (dark red) - The user has looked at, but not taken the cube and another player owns the cube. Notice the eye position indicator is on the cube (the blue sphere).
- Owned (blue) - The user has looked at and took the cube by pulling the trigger.
Each cube has the script "EyeSelection" as a component. This script handles eye tracking and controller events. When the player looks directly at a cube and pulls the trigger a message is published to PubNub to inform other players of the ownership change. When the players receive a message the cube color is updated to reflect the current state of the cube.
The tutorial Create a Multiplayer Augmented Reality Game with Magic Leap and Unity details how to build and run this project in full.
The augmented world is your oyster with Magic Leap + PubNub. Here are a few ideas to get you started:
- Build a AR chess game.
- Create a AR zombie shooter.
- Use gesture recognition to control devices like a lamp or fan.
Have suggestions or questions about the content of this post? Reach out at [email protected].
This is Part three of my Magic Leap series. Check out the other projects/posts Getting Started with Magic Leap and PubNub and Controlling Internet-connected Devices with Magic Leap Hand Gestures.