Can anyone help me to coax Unity to recognize and read input from an external accelerometer (HC-06) that is connected via Bluetooth to an Android device? The script will be attached to a game object that will respond to changes in (9) axes in near time.
Here is a cool little script by N3K EN reproduced below that would drive the game nicely if I could get Unity to play with the external accelerometer, which clips to a real-world version of the game object. I’d greatly appreciate any advice on how to expand this script to make that work.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Accelerometer : MonoBehaviour
{
public bool isFlat = true;
private Rigidbody rigid;
private void Start()
{
rigid = GetComponent<Rigidbody>();
}
private void Update()
{
Vector3 tilt = Input.acceleration;
if (isFlat)
tilt = Quaternion.Euler(0, 0, 0) * tilt;
rigid.AddForce(tilt);
}
}
A minor additional question is whether you think the internal accelerometer that is integrated into many Android (or iOS) devices needs to be disabled to make this work.
Thanks!