Raycast in 3D

I´m trying to adapt a script for pick up a object and drag it but i can´t figure out how can i pass it to 3d. The original script is for 2d:

Vector3 pos;
if(forTouchScreen)
pos = camera.ScreenToWorldPoint(Input.GetTouch(0).position);
	else
pos = camera.ScreenToWorldPoint(Input.mousePosition); 
pos.z = -1;
dragger.transform.position = pos;
RaycastHit2D  hit;
hit = Physics2D.Raycast(pos, Vector2.zero, Mathf.Infinity, layerMask);
if(!hitObject)
hitObject = hit.transform;

Can someone help??

RaycastHit hit;
Vector3pos = camera.ScreenToWorldPoint(Input.mousePosition);
if (Physics.Raycast (Vector3pos, -Vector3.up, out hit))
{

print(hit.collider.name);

}

Try this hope it will work

I think you need to check out this:

The above example takes the mouse position, which in your case will be ‘pos’, and changes it to a world position. Then use the resulting ray to pick the gameObject that you are clicking on.

It always give me error" Cannot implicitly convert typre “UnityEngine.ray to Unityengine.vector3”

Here is how i do:

Ray pos = camera.ScreenPointToRay(Input.mousePosition);
dragger.transform.position=ray;
RaycastHit hit;
if(Physics.Raycast(pos, out hit)
{

I try diferente ways but it’s always error!