Question by
phoremanish · Oct 07, 2017 at 06:22 PM ·
movementup
hi guys i have a problem with my player(Roll A Ball Game) on android, my player easily move left, right, up, down But when i tilt my phone to move player up it's too slow
using UnityEngine; using System.Collections;
[RequireComponent(typeof(Rigidbody))] public class ForceFromAccelerometer : MonoBehaviour {
// gravity constant
public float g=9.8f;
void FixedUpdate() {
// normalize axis
var gravity = new Vector3 (
Input.acceleration.x,
Input.acceleration.z,
Input.acceleration.y
) * g;
GetComponent<Rigidbody>().AddForce (gravity, ForceMode.Acceleration);
}
}
Comment
Your answer
Follow this Question
Related Questions
getting maximum x and y values of mouse position 1 Answer
Basic MOVE and JUMP script (Jump trouble) 2 Answers
Where should the Acceleration Go?! 0 Answers
Stop Audio Source Clip while button Press 1 Answer
Make character face movement direction 0 Answers