#pragma strict
var papers : int = 0;
var papersToWin : int = 8;
var distanceToPaper : float = 2.5;
public var paperpickup : AudioClip;
public var sound : audioclip;
function Start()
{
Screen.lockCursor = true;
}
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.name == “Paper” )
{
papers += 1;
audio.PlayOneShot(paperpickup);
Debug.Log( "A part was picked up. Total parts = " + papers );
Destroy( hit.collider.gameObject );
}
}
}
}
function scary()
{
if (papers === 4);
{
audio.playoneshot(scary);
}
}
function OnGUI()
{
if ( papers < papersToWin )
{
GUI.Box( Rect( (Screen.width/2)-100, 10, 200, 35 ), "Parts collected " + papers );
}
else
{
GUI.Box( Rect( (Screen.width/2)-100, 10, 200, 35 ), “Return to ship to escape” );
}
}
Areas underlined is where the problem is occuring. Probs a obvious mistake but i tried ![]()
cheers guys ![]()