Prevent player from moving outside of camera view

I’m using a virtual joystick to move the player in my top-down 2d space shooter(with 3d rigibody and colliders) and i need to prevent the player from going off-screen, i’ve done some searching on google and found some interesting stuff but some answers were either not in c# or too vague or i failed to implement them. I need it to work for different screen sizes/resolutions so i think i’m going to need this:

Vector3 screenPos = Camera.main.WorldToScreenPoint(transform.position);

and the code below is what i use to make the player move:

Vector3 moveVec = new Vector3(CrossPlatformInputManager.GetAxis("Horizontal"),0, CrossPlatformInputManager.GetAxis("Vertical"))* speed;
myBody.AddForce(moveVec);

The entire object needs to stay inside, can’t have parts sticking out

I am still getting used to unity but i think this may help. This what i would try to use. Unity - Scripting API: Mathf.Clamp