public class PlayerMove : MonoBehaviour
{
Rigidbody2D rigid;
private void Awake()
{
rigid = GetComponent<Rigidbody2D>();
}
}
Get the gameObject's Rigidbody2D componenet and set name for it. For this case it's rigid, but you can call it however you want like rb or body2D.
In the Awake(), use GetComponent<> to access and manipulate the component. We're going to manipulate Rigidbody2D here so I did
rigid = GetComponenet<Rigidbody2D>();
Make sure to put () after the <> to complete the code.
Now we can move on to actually writing the code so our player gameobject can move.