- Home /
Question by
jaiunity · Jun 15, 2012 at 01:19 PM ·
acceleration
Replace GetAxis("Vertical") and GetAxis("Horizontal") with Accelometer
Hi Everyone, I need to replace GetAxis("Vertical") and GetAxis("Horizontal") with Accelometer in my game and i have tried with some codes but seemed not working, insted my car got mad on play. Here is my piece of code: private float speed = 5.0f;
private Vector3 zeroAc;
private Vector3 curAc;
private float sensH = 10.0f;
private float sensV = 10.0f;
private float smooth= 0.5f;
private float GetAxisH = 0f;
private float GetAxisV= 0f;
/***On Upadate() *****/
curAc = Vector3.Lerp(curAc, Input.acceleration-zeroAc, Time.deltaTime/smooth);
GetAxisV = Mathf.Clamp(curAc.y * sensV, -1, 1);
GetAxisH = Mathf.Clamp(-curAc.x * sensH, -1, 1);
FrontLeftWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * (GetAxisV*speed); //Input.GetAxis("Vertical");
FrontRightWheel.motorTorque = EngineTorque / GearRatio[CurrentGear] * (GetAxisV*speed); //Input.GetAxis("Vertical");
FrontLeftWheel.steerAngle = 10 * GetAxisH;// Input.GetAxis("Horizontal");
FrontRightWheel.steerAngle = 10 * GetAxisH;// Input.GetAxis("Horizontal");
So can anyone help me with any ideas"if possible with some codes" Thanks a lot
Comment
Your answer
Follow this Question
Related Questions
Move Cube With Force and slow it down 1 Answer
Is there a better way to move my character around the screen? 0 Answers
Cloud recognition in Vuforia 0 Answers
Charecter controlled by accelaration for iphone.. 0 Answers
Invalid rank specifier error 0 Answers