In general Unity SDK target following areas
1. Prefabs for easy AR target creation
2. Easily accessible target tracking state
3. GUI for showing information layer to player
4. AR aware character control scripts
5. Helper utilities
Standard AR game workflow
- Mobile game is started. It shows introduction and main menu.
At this stage status of Ligabo is stopped.
- Payer starts a game. When scene loads up and player passes some intro and game is ready to start. Ligabo Target prefab hides automatically all scene objects and camera feed appears on the user screen.
Ligabo state should be running at this stage. if you load up new game level you can set initial state of Ligabo to running in scene game object so when scene loads up it will automatically be started. Otherwise call in your script LigaboState.status = LigaboState.Status.Running; to activate it manually.
Ligabo activates its instruction GUI screen for player to point camera of his device to Live Game Board.
At this stage Ligabo tracking state is set to notTracking. This indicates that Live Game Board is not detected in camera feed, thus player is not pointing camera to it.
Game itself should be paused at this stage.
- When player points camera to Live Game Board, LigaboState.statusTracking will change to tracking and all game objects of scene wil show up automatically. Check tracking status to start the game.
- When player points camera away from Live Game Board during game play, it is good practice to pause the game. When tracking is lost, game disapears otherwise it would appear hanging on screen rather than part of the real world. Check statusTracking regularly to determine when to stop the game. When tracking is lost, info GUI is again presented to layer instructing him to point camera back to Live Game Board.
- Player points camera back to Live game Board. Here you have 2 options. Either show game pause menu and let user to resume the game when he is ready again or just resume the game for player to continue in game play.
Explanation of SDK parts.
LigaboCamera prefab, This is the main component of AR gaming. You must keep this camera as main. Replace your main camera with LigaboCamera prefab. It will automatically make the camera view controlled by real device camera.
Ligabo prefab, just drop this one anywhere to your scene to have LigaboState initialized. It is main class where you can read AR status.
LigaboTarget prefab. You should drop this to scene, position it and size it correctly to your game content. Then make all your game objects children of LigaboTarget game object. By doing this your game will appear and disapear depending on tracking state.
LigaboMoveJoystick prefab. This is prefab for on screen jostick whcih you can position anywhere on the screen.
Ligabo state is main Ligabo object attached to Ligabo prefab. It provides option to start and stop ligabo inforamtion overlays. It gives infrormation about trackign state of live game board at any time.
This is being shown by LigaboState object when Ligabo has been started and user does not point camera on to Live Game Board thus tacking of it is not happening. Player must get clear information what he must be doing in order to play the game. This is provided automatically so you do not have to care of it.
Augmented reality aware character controls
Controlling the game is probbaly most specific area related to augmented reality. The fact that player is controlling camera all the time during playing gives option to control character by letting user point center of the camera at certain place in he scene. For this there is controler script called FollowCamera. Just attach it to your character and when you start the game, target texture will appear in the middle of the screen and caracter will follow it. If you want to use physics control and let the charater only follow position fo the pointer, turn off automatic positioning and read position values from the script to move your character in any other fasion you like. Check Space shooter tutorial to find out more about this control mode.
You can decide to use onscreen joystick to control your character, however unlike common mobile games in AR game mode camera is always changing its position and angle from which camera looks at the scene. Using standard joysticks will soon break up. To overcome this Ligabo includes FollowJoystick script whcih you can use to control you character in combination with LigaboMoveJoystick prefab. FollowJoystick prefab will continually udjust camera rotations to match what joystick direction means in actual player view perspective. Check Astro Dude tutorial to find out more about this control mode.
You can also use combination of above with nav mesh agent to send character to desired position. Use FollowCamera script with automatic position turned off. Read actual pointer position out from it when player taps on screen tap joystick and move player to that location usign nav mesh agent.
LigaboUtils class rovides some utilities we found important when working with AR games.
It gives constantly updated camera correction angle of camera and scene foraward axis so you can udjust positioning and controls accordingly.
There is also GUI scaler tool which makes your GUI adapted to different kind of screen resolutions and device rotation.
To use it you need to use relative GUI not GUILayout. You should define positioning of buttons and other UI elements related to edges of the screen. Then replace all usage of Screen.width by LigaboUtils.screenWidth and same for heigh.
Desing your UI as it would be for screen size 960px width and 540px heigh when in landscape. And you are done, all screen resolutions and rotation will fit for you autoamtically including font size.
Now when you know more or less what our SDK gives you lets get to the work! ;o)