Guest User

Untitled

a guest
Feb 19th, 2018
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.39 KB | None | 0 0
  1. public class PhysicsMovement : MonoBehaviour
  2. {
  3. private float _maxSpeed = 5f;
  4. private Rigidbody2D _rigidbody2;
  5.  
  6. // Use this for initialization
  7. void Awake ()
  8. {
  9. _rigidbody2 = GetComponent<Rigidbody2D>();
  10. }
  11.  
  12. private void FixedUpdate()
  13. {
  14. float move = Input.GetAxis("Horizontal");
  15.  
  16. // Add velocity to player
  17. _rigidbody2.velocity = new Vector2(move * _maxSpeed, _rigidbody2.velocity.y);
  18. }
  19. }
Add Comment
Please, Sign In to add comment