using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMovementScript : MonoBehaviour
{
    
    public float movementSpeed;
    private Rigidbody2D rigidBody;
    private float xAxis = 0f;
    private float yAxis = 0f;

    void Start()
    {
        rigidBody = this.GetComponent<Rigidbody2D>();
    }


    void FixedUpdate()
    {
        Movement();
    }

    void Movement()
    {
        xAxis = Input.GetAxis("Horizontal");
        yAxis = Input.GetAxis("Vertical");
        rigidBody.velocity = new Vector2(xAxis * movementSpeed, yAxis * movementSpeed);

        transform.position = new Vector3(Mathf.Clamp(this.transform.position.x, -6.2f, 6.4f), Mathf.Clamp(this.transform.position.y, -5, 2), 0.0f);
             
    }
}
