Physics.Raycast to Physics2D.Raycast?

I’m editing a script that was made for Unity 3D, and need to make it work for 2D. I’ve got it all pretty good besides an overloaded method error. Here’s the part thats giving me trouble…

if (Physics2D.Raycast(Camera.main.ViewportPointToRay(new Vector3(0.5f, 0.5f, 0.5f)), out hit, 5f))
		{
            if (hit.collider != null)
            {
                if (hit.collider.GetComponent<UI_Item>() != null)
                {
                    go = hit.collider.gameObject;
                    displayMessage = true;
                }
                else
                {
                    displayMessage = false;
                    go = null;
                }
            }
            else
            {
                displayMessage = false;
                go = null;
            }
        }

I’m pretty new to C#, and coding in general, so any help is awesome! Thanks :).

A look at the Unity Scripting API tell me that the Physics2D.RayCast function takes a Vector2 as a parameter, as opposed to the Vector3 you try to pass it. The other parameters are listed on the page as well. I am under the impression that the 2D version is a lot less flexible when it comes to parameter options, but that just as a side node :wink: