AR Camera Lite — Unity Asset that uses Back/Rear Camera & Motion Sensor (Gyroscope or Accelerometer) on the player’s mobile device to display 2D or 3D objects as though they were in the real world. It’s Fast, Markerless, Pseudo Augmented Reality.
- 1 Features of AR Camera Lite
- 2 Package Contains
- 3 Gyro vs. Accelerometer
- 4 Limitations
- 5 Use Cases of AR Camera Lite
- 6 Tutorial
- 7 Testing
- 8 Known issues
- 9 Support
- 10 Changelog
Features of AR Camera Lite
Bring the enchanting Power of Augmented Reality into your amazing Game or App:
- Covering a Wide Range of Mobile Devices. Such pseudo AR can work on low-budget smartphones.
- No using of other AR Engines like AR Foundation (ARCore, ARKit), Vuforia, etc.
- Auto Rotation: Portrait, Landscape.
- Auto Selection of Sensor: Gyroscope or Accelerometer.
- Gyroscope Mode: same AR like in the Pokemon GO game (AR mode, not AR+): 3DoF — it can track rotational motion but not translational.
- Accelerometer Mode (horizontal rotation is limited): tilting the phone to the left or right rotates the camera about the Y-axis.
- Instant Launch after granting the camera permission: no need to scan the environment, because there is no surface/plane detection.
- Quick Testing in Unity Editor without Smartphone through the Right Mouse Button.
- Real-Time AR Shadows.
Read more about Top AR Engines for Unity.
- Demo with Cubes & AR Shadows (docs): shader is included.
- Separate Scene with Camera Permission Request using free Native Camera.
Gyro vs. Accelerometer
90% of all mobile devices have an accelerometer and video camera but only 40% have a gyroscope.
If the user’s smartphone has a Gyroscope, then it will be used for camera motion first. Otherwise, an Accelerometer will be used, because it has less accuracy & stability than a Gyroscope in the case of AR.
Hardware nuances of the gyroscope & accelerometer (asset code does not affect it):
- Different devices have different sensors, and therefore different deviations and drifts.
- Drift is natural for the mobile sensors.
Pro Gamer Tip
Accelerometer & Gyroscope are used in games and apps to control gameplay like in PUBG MOBILE game. Sometimes these sensors can be set up incorrectly for some reason & break the gameplay. If you guess that your drift of gyro or accelerometer is not normal, then try to calibrate them with system tools provided by your smartphone manufacturer.
Use Cases of AR Camera Lite
This tutorial is relevant for AR Camera Lite 4.1+.
Tutorial for AR Camera GYRO asset can be found only in asset folder.
Getting Started with AR Camera Lite
Folders & Files in the package by default:
- Makaka Games.
If you have any issues with the first launch then just Reach Support with Invoice Number and Get Help.
If you read this tutorial from PDF, first check the latest docs online to get actual information.
- Create New Unity Project with Unity 2021.1.12.
- File > Build Settings > iOS or Android > Switch Platform.
- Next Packages must be manually installed with Git & Unity Package Manager:
- Download and import AR Camera Lite into Unity.
- Warning Windows:
- Click “Import” to overwrite the Project Settings with predefined ones.
- Click “Install/Upgrade” for Package Manager Dependencies.
- Warning Windows:
- Next Packages are provided with Unity Package Manager, and they are already installed for this Asset by default. If packages are missing (Warning Window did not appear) then install them again with Unity Package Manager:
- TextMesh Pro 3.0.6:
- Always Required: Window > TextMeshPro > Import TMP Essential Resources.
- TextMesh Pro 3.0.6:
- Reopen Unity Project.
- Open Scene: Makaka Games > AR > AR Camera Lite > Scenes > Demo.
- Test in the Unity Editor or Build for Mobile.
Useful Article: How to Test iOS App without Developer Account?
Video Tutorial was made for the previous version of the asset, but it still can be useful to understand how to transform your scene to AR. So use the text tutorial first.
AR Camera GYRO prefab & GyroCameraControl.cs
ARCameraGYRO prefab has main camera control script: GyroCameraControl.cs.
Optional Flag: Is Gyro Disabled On Destroy
If it’s ‘true’ then Gyro’s “Y” Rotation is reset on Scene Closing or Reloading. Useful if you need to Control the Start Rotation of Camera when Restart.
Optional Event: On Gyro Initialized
The case when the smartphone has the gyroscope.
Optional Event: On Gyro Is Not Supported
The case when the smartphone has not the gyroscope. By default, you will see a screen message: “Your device does not support gyroscope…”.
Optional Event: On Initialized in Editor
The case when Play Mode in Unity Editor.
There are 2 ways of testing without building an app:
- Testing with Unity Remote & Smartphone connected to Computer.
- Testing without a Smartphone.
Testing without the Smartphone
You can test camera rotation quickly in Unity Editor without Smartphone through the Right Mouse Button.
Also, you can use WASDQE keys to move the camera.
Use Fullscreen of Game View in Unity Editor while testing to get a seamless experience.
Accelerometer Instead of Gyro
You can forcibly test Game Version with accelerometer on gyro supported devices:
Hierarchy View > ARCameraGYRO > GyroCameraControl > Is Gyro Unsupported Not In Editor Test > Check, then Build And Run.
Also, you can start the scene with Predefined Data of position & rotation. It’s a convenient way to frequently testing the same positions and rotations of the camera: “GyroCamera” Game Object.
So you can save these data with custom Transform components on Game Objects as shown on the screenshot: as children of “TestViewWithoutGyro” Game Object.
These transform components are parameters for the function called SetPositionAndRotation (Transform transform) which is executed on game start when “OnGyroIsNotSupported” event is called (i.e. Unity Editor environment or Smartphone without Gyroscope).
I used this testing method when developing AR Basketball GO (docs). I needed to periodically test Normal Ball (with touching of Ring) & Clear Ball (without touching of Ring). Since throw “Clear Ball” is a hard task, I saved 2 different camera Transform components to change them when needed:
- Right Above the Ring;
- A Few Meters from the Ring.
Testing Time was decreased well because I didn’t need to take the mobile phone every time in my hands after changes in the game logic & move the phone manually. Instead of it, I had predefined data.
Tested with Devices
- iOS on iPhone 6, 8, XS Max.
- Android on Samsung Galaxy A71.
- UWP on Microsoft Surface Pro 5, Acer Switch 5.
Unity AR bugs: Gyroscope
Hardware Issue: INPUT.GYRO.ATTITUDE returns zero values on Motorola Moto G4 and G5.
Black screen on iOS
You just need to fill Camera Usage Description in Unity Editor.
Go to Unity Editor > Player Settings > iOS > Other Settings > Camera Usage Description > Fill it (any note for your app).
Zoom Effect of Camera Feed
Zoom Effect in Portrait Mode is related to how Unity gets the camera texture on your phone.
When Camera Texture is not equal to screen size, then the asset automatically zooms it to avoid the black zones on the sides.
You can play with parameters in “Aspect Ratio Filter” Component of “RawImageCameraAsBackground” game object and correct the behavior as you want.
Check the current version on Asset Store.
The latest versions will be added as soon as possible.
- Testing Checkboxes:
- Is Gyro Unsupported Not In Editor Test,
- Is Gyro Supported In Editor Test,
- Is Movement WASDQE In Editor Test.
- Testing Vector3: Movement WASDQE Speed.
- On Gyro Initialized,
- On Initialized In Editor.
- Native Camera 1.2.9.
- Limited Motion with Accelerometer (will be used if the user device has not Gyroscope).
- Editor Testing with Right Mouse Button.
- Using of Native Camera to check Camera Permission before the main scene.
- Unity 2021.1.0.
- New Way of Testing in Unity Editor (On Gyro is not supported) with custom positions and rotations of camera. The phone does not need to be connected to the computer.
- Tutorial Texts → TextMesh Pro.
- Unity 2019.3.0.
- Optional Flag: “Is Gyro Disabled On Destroy”.
- Optional Unity Event “On Gyro Is Not Supported”.
- Unity 2019.1.
- Unity 2018.3;
- Fix low FPS in Unity Editor;
- 2 modes with Auto Rotation: Portrait, Landscape.