Error in code? SOLVED

#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 :confused:

cheers guys :stuck_out_tongue:

[ code ] [/ code] tags on pasted code…

and you’ve missed the capitalisation on the audioclip (ie AudioClip not audioclip)
and equals (ie is this the same as that?) is ==

I know but cant underline code in the code boxes. Thanks for your input but that is not the problem, i changed the loads

When you use the code tags, there are line numbers and you can refer to them. It is a lot easier to read formatted code than just a text without indentation.

1 Like

I would just like to apologise for the awful post. Code isnt formatted and i didnt go into detail what the issue was. This was one of the first scripts i wrote in c#. Im much more advanced now and can understand its annoying when posts like these are made. Sorry and thanks!

1 Like