Unity Assets

AR Camera Lite

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.

Unity Asset Store | Download Button

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.

Package Contains

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.

Limitations

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

Tutorial

This tutorial is relevant for AR Camera Lite.
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.

Steps

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.

  1. Create New Unity Project with Unity 2021.1.0
  2. Build Settings > iOS or Android > Switch Platform.
  3. Next Packages must be manually installed with Git & Unity Package Manager:
    1. Native Camera 1.2.7
  4. Download and import AR Camera Lite into Unity.
    1. Warning Windows:
      1. Click “Import” to overwrite the Project Settings with predefined ones.
      2. Click “Install/Upgrade” for Package Manager Dependencies.
  5. 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:
    1. TextMesh Pro 3.0.4:
      1. Always Required: Window > TextMeshPro > Import TMP Essential Resources.
  6. Reopen Unity Project.
  7. Open Scene: Makaka Games > AR > AR Camera Lite > Scenes > Demo.
  8. 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.

Script Manual

AR Camera GYRO prefab & GyroCameraControl.cs

AR Camera Lite — Unity Asset — Augmented Reality with Gyroscope & Accelerometer

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 Is Not Supported

Here you can easily assign your own functions in case that smartphone doesn’t have the gyroscope. By default, you will see a screen message: “Your device does not support gyroscope”.

Optional Event: On Runtime Started in Editor

Here you can easily assign your own functions only for Play Mode in Unity Editor.

Testing

There are 2 ways of testing without building an app:

Testing without the Smartphone

You can test camera rotation quickly in Unity Editor without Smartphone through the Right Mouse Button.

Predefined Data

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.

AR Camera GYRO — Unity Asset — Testing without Smartphone

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).

Use Case

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:

  1. Right Above the Ring;
  2. 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

Mobiles:

  • iOS on iPhone 6, 8, XS Max.
  • Android on Samsung Galaxy A71.

Tablets:

  • UWP on Microsoft Surface Pro 5, Acer Switch 5.

Known issues

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 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.

Support

First, read the latest docs online.
If it didn’t help, get the support.

Changelog

Check the current version on Asset Store.
The latest versions will be added as soon as possible.

4.0:

  • 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.

3.3:

  • 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.

3.2:

  • Optional Flag: “Is Gyro Disabled On Destroy”.
  • Optional Unity Event “On Gyro Is Not Supported”.

3.1:

  • Unity 2019.1.

3.0:

  • Unity 2018.3;
  • Fix low FPS in Unity Editor;
  • 2 modes with Auto Rotation: Portrait, Landscape.

2.0:

  • ARCameraGYRO prefab (with all stuff inside);
  • AR Shadow (docs) (shader is included);
  • Unity 2017.3.1;
  • AR Background → as independent module;
  • GyroCameraControl.cs not related with GameWorld GameObject.
Unity Assets

Support for Unity Assets

I am Andrey Sirota, Founder of Makaka Games and full-time Publisher on Unity Asset Store. First, read the latest docs online. If it didn’t help, get the support.

Related Articles

Leave a Reply

Your email address will not be published. Required fields are marked *

Comment moderation is enabled. Your comment may take some time to appear.

Back to top button