Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class PhysicsMovement : MonoBehaviour
- {
- private float _maxSpeed = 5f;
- private Rigidbody2D _rigidbody2;
- // Use this for initialization
- void Awake ()
- {
- _rigidbody2 = GetComponent<Rigidbody2D>();
- }
- private void FixedUpdate()
- {
- float move = Input.GetAxis("Horizontal");
- // Add velocity to player
- _rigidbody2.velocity = new Vector2(move * _maxSpeed, _rigidbody2.velocity.y);
- }
- }
Add Comment
Please, Sign In to add comment