Greetings people.
(Background)
Been busy the last couple of days completing all the Unity tutorials and some user made videos.
So i’ve been playing around with the rollball tutorial after completing it.
And thought id like to play with this on my tablet, so after enabling debug + connecting with remote and it works out of the box.
I’ve tryed adding joysticks (invisible ones included in the standard assets. And everything is top notch ![]()
(Actual issue)
Now i want to try learn about the accelerometer and gyro. I have confirmed that my tablet has both availible so time for testing.
I’ve changed the code a bit, from line 29 to 43 is where i attempt to make use of the accelerometer, but fails.
void FixedUpdate()
{
Vector3 dir = Vector3.zero;
dir.x = -Input.acceleration.y;
dir.z = Input.acceleration.x;
if (dir.sqrMagnitude > 1)
dir.Normalize ();
dir *= Time.deltaTime;
transform.Translate (dir * speed);
Vector3 movement = new Vector3 (dir.x, 0.0f,dir.z);
rigidbody.AddForce (movement * speed * Time.deltaTime);
}
The issues I’m experiencing are
- No constant force being added to the player - movement stops even with the tablet tiltet
- It actually jumps “upwards” out of the board - it should not.
- The jumping is only Down- and Left- wards.
- Directions are registere oposite the tilt, it always rolls “uphill”
(EDIT/Update)
Just tryed playing around with the gyro using
dir.x = Input.gyro.userAcceleration.x;
dir.y = Input.gyro.userAcceleration.y;
To catch the tilt of the tablet, but then i have no movement.
Do you guys have some advice ?