Rolling Character Accelerometer Controls
THIS IS MY CODE using System.Collections; using System.Collections.Generic; using UnityEngine; public class BallMovement : MonoBehaviour { public bool isflat = false; private Rigidbody rigid; private void Start() { rigid = GetComponent<Rigidbody>(); } private void Update() { Vector3 tilt = Input.acceleration; if (isflat) tilt = Quaternion.Euler(90, 0, 0) * tilt; rigid.AddForce(tilt); } }
what i want it to do is when my phone is facing forward the ball rolls forward and when it is tilted backwards the ball rolls backwards but the controls are inverted to the way i would like and i cant find a way to change them.
Your answer
Follow this Question
Related Questions
How do I pause the accelerometer? 1 Answer
Problem with Android platform 0 Answers
Unity BLE Bluetooth from BNO055 connected to Arduino 2 Answers
Getting linear acceleration not using gyroscope on Android 2 Answers
Precise Gravity Based on Accelerometer 0 Answers