Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Move : MonoBehaviour {
- public float speed;
- private Rigidbody2D rb2d;
- // Use this for initialization
- void Start () {
- rb2d = GetComponent<Rigidbody2D>();
- }
- // Update is called once per frame
- void Update () {
- }
- void FixedUpdate()
- {
- float moveHorizontal = Input.GetAxis("Horizontal");
- float moveVertical = Input.GetAxis("Vertical");
- Vector2 movement = new Vector2(moveHorizontal, moveVertical);
- rb2d.AddForce(movement * speed);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement