Question by
elliotho · Jul 23, 2017 at 04:14 PM ·
mobilegameaccelerometertoggle button
Trying to get a toggle button to turn the accelerometer off in my game
Settings Script public class Settings : MonoBehaviour {
private PlayerMovement Acc;
public void Start()
{
Acc = GetComponent<PlayerMovement>();
}
public void Quit()
{
Debug.Log("Exited Game");
PlayerPrefs.Save();
Application.Quit();
}
public void AccOn()
{
if (Toggle.)
}
}
PlayerMovement Script public class PlayerMovement : MonoBehaviour {
public Rigidbody rb;
public float forwardForce = 2000f;
public float sidewaysForce = 500f;
void FixedUpdate () {
rb.AddForce(0, 0, forwardForce * Time.deltaTime);
if( Input.GetKey("d"))
{
rb.AddForce(sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (Input.GetKey("a"))
{
rb.AddForce(-sidewaysForce * Time.deltaTime, 0, 0, ForceMode.VelocityChange);
}
if (rb.position.y < -1f)
{
FindObjectOfType<GameManager>().EndGame();
}
float temp = Input.acceleration.x; //Debug.Log(temp);
transform.Translate(temp, 0, 0);
}
}
Trying to save the settings when player exits the game aswell but no idea what to do. Many thanks
Comment
Your answer
Follow this Question
Related Questions
Button to do two actions ?, 0 Answers
Problem with Android platform 0 Answers
Use quaternion(s) to rotate the accelerator reading 0 Answers
Delayed particle effect? 0 Answers