Sensor Camera: ✅ Gyroscope & Accelerometer — Unity Asset

Sensor Camera — Unity Asset that uses a Motion Sensor (Gyroscope or Accelerometer) on the player’s mobile device to control the game camera from a first-person view (just like in FPS Games). Safety First.

Read Documentation.

It doesn’t use live video input from the Back/Rear Camera of a Mobile Device like in AR Camera Lite.


Features of Sensor Camera

Bring the enchanting Power of Mobile Sensors into your amazing Game or App:

  • First-Person Camera controlled by Motion Sensors.
  • Auto Selection of Sensor: Gyroscope or Accelerometer.
  • Auto Rotation: Portrait, Landscape.
  • Gyroscope Mode: 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 around the Y-axis.
  • Quick Testing in Unity Editor without a Phone through the Right Mouse Button & WASDQE keys.

Use Cases of Sensor Camera

With adding live video input from the Back/Rear Camera of a Mobile Device, Sensor Camera can be used as a “Pseudo AR Camera” to display 2D or 3D objects as though they were in the real world.

This technique was implemented in AR Camera Lite.


AR Shooter.


AR Basketball.

Sensor Camera :star: Update

v1.2:

Fixes:

  • Camera Y Rotation Sensitivity with Accelerometer for Different FPS.

v1.1 (New Settings of Accelerometer – can be set in Unity Editor):

Features:

  • Checkboxes for Testing:

  • Is Accelerometer Unsupported Not In Editor Test;

  • Is Accelerometer Supported In Editor Test.

  • Events:

  • On Accelerometer Initialized;

  • On Accelerometer Is Not Supported.

I released the Sensor Camera 2.0 for Unity 2022.3.6 with WebGL Support via HTTPS for Android

But Why is WebGL only available for Android? Because the Unity WebGL platform has a bug on iOS in Safari and Chrome with Orientation Changing:

when you change device orientation during the game, then it is not defined correctly sometimes. Solution: warn the player about making correct orientation before starting of Unity Project on a new tab.

At the same time, I tested a standalone app on the iOS platform: works like a charm!


All Tested Platforms are here:

Mobile Platforms with Motion Sensors:

  • iOS on iPhone 8, XS Max;
  • Android on Samsung Galaxy A71;
  • WebGL (Android) in Google Chrome.

Desktop Platforms with Right Mouse Button (for those who want a similar and seamless experience on all platforms):

  • Windows;
  • macOS;
  • WebGL in Google Chrome.

Today, I submitted 2 Bug Reports to Unity related to the next issues:

  • [WebGL > iOS]: Incorrect Orientation Changing, which leads to publishing without issues to the [WebGL > Android] platform only, as well as to iOS and Android platforms [standalone].
  • Resolving this bug by Unity will lead to the opportunity to publish WebGL apps for iOS.*
  • [iOS]: Delay and Freezing in Unity’s New Input System related to the Attitude Sensor. This bug doesn’t influence the asset because for iOS and Android standalone platforms it uses Input Manager instead (Unity’s Input System by Default).
  • But resolving this bug by Unity will lead to further asset upgrading and smooth development.*

Bug Reporting took several hours.

For your clear understanding, Working Platforms with Motion Sensors at this moment:

  • iOS on iPhone 8, XS Max;
  • Android on Samsung Galaxy A71;
  • WebGL (Android) in Google Chrome.

I continue to work, stay tuned. The Unity Asset is Here: Sensor Camera.


You can vote for the bug resolving on Unity Issue Tracker. Please vote.


1 Like

Tutorial: How to Build & Test Sensor Camera for Mobile WebGL

> Complete Article with all Links and Commands <

Unity Asset: Sensor Camera



You also can vote for another the bug resolving on Unity Issue Tracker. Please vote.


Workaround for iOS WebGL: warn the player about making correct orientation before starting of Unity Project on a new tab.

I released the Sensor Camera 2.1 for Unity 2022.3.18 with WebGL Support via HTTPS for iOS

The bug with orientation changing was fixed by Unity without confirmation. The previous state of bug was “Won’t Fixed”. Today I updated the ticket in Unity’s Jira and status was changed to “Active”.

I tested with Google Chrome on iPhone XS Max, Unity 2022.3.18, Input System 1.7.0 and my Sensor Camera asset. I can see that orientation changes to correct orientation after setting the wrong orientation. So the problem was resolved.

1 Like