Picking up my mouseover click problem

What i am going for here is if the mouse cursor is clicked, while over the paper with the collider, with the tag “Paper” i want it to pickup and add a 1 to the photo list, that’s working and all, but the problem is, the picking up of the paper, the code works just fine when it is a collider.

Here is my code -

var Paper : int = 0;
var paperToWin : int = 9;
var paperpickup : AudioClip;

function Start() {
} 

function Update() { 
}

function OnMouseUp( other : Collider ) {
    	if (other.gameObject.tag == "Paper"){
       	Paper += 1;
       	audio.PlayOneShot(paperpickup);
       	Debug.Log("A paper was picked up. Total papers = " + Paper);
       	Destroy(other.gameObject);
    	}
}

function OnGUI()
{
    if (Paper < paperToWin)
    {
       GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "" + Paper + " Papers");
    }
    else
    {
       GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "All Papers Collected!");
    }
}

I have never had success with the EventType.Mouse commands in Unity, therefore have found Raycasting to be more accurate, useful and flexible.

Here is your script but with using a raycast.

Note the variable distanceToPaper , this works so that the player has to be close to the paper to click it, it is currently set to 4.0 units but you can change this to what works best; e.g. if you see a paper in the distance, you have to walk up to it, not be able to click it from far away :

var Paper : int = 0;
var paperToWin : int = 9;
var paperpickup : AudioClip;

var distanceToPaper : float = 4.0;

function Start() 
{
	
} 

function Update() 
{ 
    if ( Input.GetMouseButtonUp(0) )
    {
        var ray = Camera.main.ScreenPointToRay( Input.mousePosition );
        var hit : RaycastHit;
        if ( Physics.Raycast( ray, hit, distanceToPaper ) )
        {
            if ( hit.collider.gameObject.tag == "Paper" )
            {
	            Paper += 1;
	            audio.PlayOneShot(paperpickup);
	            Debug.Log("A paper was picked up. Total papers = " + Paper);
	            Destroy( hit.collider.gameObject );
            }
        }
    }
}

function OnGUI()
{
    if (Paper < paperToWin)
    {
       GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "" + Paper + " Papers");
    }
    else
    {
       GUI.Box(Rect((Screen.width/2)-100, 10, 200, 35), "All Papers Collected!");
    }
}

So many ‘Slender’ questions, it is sending me silly.

I recognize the variable names and the OnGUI function from another of my answers! Using the trigger method : http://answers.unity3d.com/questions/239927/Collecting-Papers-and-Keeping-Track-of-how-many-collected--need-help.html)

Nice job of including sound, well done. You may be interested in these links :

http://forum.unity3d.com/threads/134862-Slender-Man-Design-Outline (read all the pages! easter eggs…)

Hope this helps =]