Advertisement
GabrielRabeloLopes

Accelerometer

Dec 27th, 2015
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. public class Move : MonoBehaviour
  2. {
  3. public float sensibility = 21;
  4. public float pc;
  5.  
  6. void Update()
  7. {
  8. if (gameObject.transform.position.x <= -3)
  9. {
  10. gameObject.transform.position = new Vector3(-3, gameObject.transform.position.y, gameObject.transform.position.z);
  11. }
  12. if (gameObject.transform.position.x >= 3)
  13. {
  14. gameObject.transform.position = new Vector3(3, gameObject.transform.position.y, gameObject.transform.position.z);
  15. }
  16. gameObject.transform.position += new Vector3(Input.acceleration.x + pc, 0, 0) * Time.deltaTime * sensibility;
  17. }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement