Advertisement
ZemaToxic

Untitled

Jul 19th, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.54 KB | None | 0 0
  1. public class Move : MonoBehaviour {
  2.  
  3. public float speed;
  4.  
  5. private Rigidbody2D rb2d;
  6.  
  7.  
  8. // Use this for initialization
  9. void Start () {
  10.  
  11. rb2d = GetComponent<Rigidbody2D>();
  12.  
  13. }
  14.  
  15. // Update is called once per frame
  16. void Update () {
  17.  
  18. }
  19.  
  20. void FixedUpdate()
  21. {
  22. float moveHorizontal = Input.GetAxis("Horizontal");
  23. float moveVertical = Input.GetAxis("Vertical");
  24.  
  25. Vector2 movement = new Vector2(moveHorizontal, moveVertical);
  26.  
  27. rb2d.AddForce(movement * speed);
  28.  
  29. }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement