Get mouse positon in world coordinates on a plane?

I’ve been trying the methods described here: 1.
But this is giving me a lot of errors. I can’t retrieve the objects I need for these functions. The exact method described there gives me errors saying that the objects don’t exist.

If I then do GameObject.FindGameObjectWithTag() I will get errors saying that GameObject.FindGameObjectWithTag does not have the functions described in my link.

If I do a GetComponent<>, it can’t find the objects.

Any idea what I could try?

EDIT: The method that seems to be giving the least errors is:

if (plane.Raycast(mainCamera.ScreenPointToRay(Input.mousePosition),enter))
			drawingPosition = mainCamera.ScreenPointToRay(Input.mousePosition).GetPoint(enter);

But I can’t figure out what I should fill in in the “out float enter” parameter. The documentation isn’t particularly helpful either; it doesn’t even mention that parameter (2)

See if this is what you're looking to do -->

var rodentButton : int = 0 ; //set to left mouse button with '0', can change in inspector
var rodentRange : float = 250.0 ; //set in inspector how far into 3d space from the screen you can click
var tagger : String = "MyPlaneTag" ; //set this in inspector to whatever you tag your plane/whatever
function Update(){
      FindTheCheese() ;
function FindTheCheese(){
   var ray : Ray = Camera.main.ScreenPointToRay(Input.mousePosition) ; //make sure you have a camera in the scene tagged as 'MainCamera'
   var hit : RaycastHit ;
   if(Physics.Raycast(ray, hit, rodentRange)){
         //do whatever you're wanting to do here...
      Debug.Log("World coordinates of our mouse click = " +hit.point) ; //a debug so you can see what it's returning. "hit.point" here is what returns the coordinates


I'm not too sure about C# or splitting up functions in it, but here's my best guess at translating the above and just putting it all into the update() ->

using UnityEngine;
using System.Collections;

public class NameItWhatever : MonoBehaviour {
public int rodentButton = 0;
public float rodentRange = 250.0f;
public string tagger = "MyPlaneTag";
void Update(){
      Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
      RaycastHit hit;
         if(Physics.Raycast(ray, out hit, rodentRange)){
                //do whatever......

If you know the equation of the plane you can do something like this:

        Vector3 planeNormal = new Vector3(0f, 1f, 0f);
        Vector3 planeCenter = plane.transform.position;
        Ray cameraRay = Camera.main.ScreenPointToRay(Input.mousePosition);
        Vector3 lineOrigin = cameraRay.origin;
        Vector3 lineDirection = cameraRay.direction;

        Vector3 difference = planeCenter - lineOrigin;
        float denominator = Vector3.Dot(lineDirection, planeNormal);
        float t = Vector3.Dot(difference, planeNormal) / denominator;

        // INTERSECTION:
        Vector3 planeIntersection = lineOrigin + (lineDirection * t);

I found this helpful:

Intuitively you put the equation of your ray into the plane equation to solve for the distance from the origin the line intersects the plane, then plug that back into the ray equation to find the point on the plane.