Advertisement
Guest User

Untitled

a guest
Feb 25th, 2018
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. void Update ()
  2. {
  3. Move();
  4. Lose();
  5. MoveAcc();
  6. }
  7. public void Move()
  8. {
  9. if (Input.GetAxisRaw("Horizontal") > 0)
  10. {
  11. transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0, 0));
  12. }
  13. if (Input.GetAxisRaw("Horizontal") < 0)
  14. {
  15. transform.Translate(new Vector3(Input.GetAxisRaw("Horizontal") * moveSpeed * Time.deltaTime, 0, 0));
  16. }
  17. }
  18.  
  19. public void MoveAcc()
  20. {
  21. float acc = Input.acceleration.x;
  22.  
  23. transform.Translate(acc, 0, 0);
  24. }
  25. public void Lose()
  26. {
  27. if(transform.position.x <= -3 || transform.position.x >= 3 )
  28. {
  29. loseCanvas.gameObject.SetActive(true);
  30. Time.timeScale = 0;
  31. }
  32. }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement