TeHArGiS10

Untitled

Feb 15th, 2017
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. using UnityEngine;
  2.  
  3. public class Controller : MonoBehaviour {
  4.  
  5. public int speed = 1;
  6.  
  7. void Update ()
  8. {
  9. float mouseX = Input.GetAxisRaw("Mouse X");
  10. float vel = mouseX * speed;
  11.  
  12. if (mouseX != 0)
  13. {
  14. gameObject.GetComponent<Rigidbody>().isKinematic = false;
  15.  
  16. if (mouseX < 0)
  17. {
  18. gameObject.GetComponent<Rigidbody>().velocity = new Vector3(vel, 0, 0);
  19. }
  20. else
  21. {
  22. gameObject.GetComponent<Rigidbody>().velocity = new Vector3(vel, 0, 0);
  23. }
  24. } else
  25. {
  26. gameObject.GetComponent<Rigidbody>().isKinematic = true;
  27. }
  28. }
  29.  
  30. }
Advertisement
Add Comment
Please, Sign In to add comment