An online version of сomplete documentation for my Unity AR Assets with Augmented Reality.
AR Camera GYRO
Note: Cross-platform mobile camera implements markerless augmented reality (AR) by using a gyroscope (like Pokemon GO).
AR Camera GYRO uses the camera and gyroscope on the player’s mobile device to display 2D or 3D objects as though they were in the real world.
All modules are designed independently to keep this asset extendable & easy to understand.
Gyro vs. Accelerometer
90% of all mobile devices have an accelerometer and video camera but only 20% have a gyroscope.
If you want greater coverage of devices, but less accuracy and stability, use AR Camera ACCELEROMETER.
If you want greater accuracy and stability, use AR Camera GYRO.
You can also try to use both cameras for different cases.
Different devices have different gyroscopes, and therefore different deviations and drifts.
— iOS on iPhone 6.
— Android on Samsung Galaxy S7, Lenovo A606.
GyroCamera.cs & GameWorld
The Main Camera has a script (GyroCamera.cs), which refers to the GameWorld. Place inside GameWorld all objects you want to see in Augmented Reality.
Interface into the Gyroscope. Use this variable to access gyroscope.
Is a gyroscope available on the device?
rotationFix = new Quaternion (0f, 0f, 1f, 0f);
It corrects a position of the camera every Update () call.
You can assign a function (in the inspector) to be executed if the gyroscope is not supported by your smartphone.
Unity AR bugs: Gyroscope
- INPUT.GYRO.ATTITUDE returns zero values on Motorola Moto G4 and G5.
- INPUT.GYRO is extremely laggy on Samsung Galaxy S6, S6 Edge and S8 with Android 7.0.
- INPUT.GYRO.ATTITUDE returns acceleration’s values: Fixed in Unity 2017.2.
Vote on these issues and comment them.
It’s important for Unity Team, so users should pay them attention to the situation.
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).
Package contains demo with Vuforia.
— iOS on iPhone 6.
— Android on Lenovo A606.
Getting started from scratch
- Go to Edit > Project Settings > Quality.
- Choose Default Quality Level for a target platform.
- Shadow Projection = Close Fit.
- Shadow Distance = 400.
- Create Plane (ARGround prefab).
- Place plane on the marker (a bit higher) if you use marker AR like Vuforia. If you use markerless AR (e.g. AR Camera GYRO) then place the plane on your origin so you can see the shadows.
- Resize plane for all your active area of game action.
- Attach ARShadow material with ARShadowSurface shader (AR/ARShadowSurface) to the Plane.
- Cutout = 1.
- Create Direction Light (ARDirectionalLight prefab).
- Intensity = 1.5.
- Shadow Type = Soft Shadows.
- Strength = 0.323.
- Bias = 0.13.
- Normal Bias = 0.
- Near Plane = 0.9.
- Press Play and see the AR shadows from objects.
Unity 2017.2 integrates the Vuforia Engine.
You can learn more about new pipeline on Vuforia Developer Portal.
Why does not Vuforia work?
- Vuforia Developer Portal > Develop > License Manager > Get Development Key.
- Go to Window > Vuforia Configuration > App License Key > Paste your Key.
- File > Save Project.
Build & Run on mobile
If you have errors when you try to make a build for mobile platform:
- Go to Unity Editor > Player Settings > Target Platform > XR Settings.
- Check the “Vuforia Augmented Reality Supported”.
First of all, read this documentation for Unity AR.
If it didn’t help, get the support.