- Home /
Insert Semicolon error
When i make a script some times it says insert a semicolon but there already is a semi colon on the line it tells me to put it on so can someone help me out with this problem?
here is the code:
#pragma strict
public var objectToSpawn : GameObject;
public var horizontalOffset : float = 10.0f;
public var minVerticalOffset : float = 0.0f;
public var maxVerticalOffset : float = 3.0f;
public var minTimeBetweenSpawns : float = 1.0f;
public var maxTimeBetweenSpawns : float = 5.0f;
private var spawnTimer : float = 0.0f;
private var spawnTime : float = 0.0f;
function Start ()
{
spawnTime = minTimeBetweenSpawns + Random.value*(maxTimeBetweenSpawns - minTimeBetweenSpawns);
}
function Update ()
{
spawnTimer += Time.deltaTime;
if(spawnTimer >= spawnTime)
{
Vector3 spawnPosition = Camera.main.transform.position;
spawnPosition.x += horizontalOffset;
spawnPosition.y = minVerticalOffset + Random.Value*(maxVerticalOffset - minVerticalOffset);
spawnPosition.z = 0;
//Spawn our Object
Instantiate(objectToSpawn, spawnPostition, objectToSpawn.transform.rotation);
//Reset Timer and Time
spawnTimer = 0.0f;
spawnTime = minTimeBetweenSpawns + Random.value*(maxTimeBetweenSpawns - minTimeBetweenSpawns);
}
}
What line is the error on, it might be a bracketing problem
I think the Random.Value part looks a little funky. $$anonymous$$aybe cause it's in JavaScript, but it looks like you're trying to do this:
Random.Range($$anonymous$$,max);
@jacobschellenberg thanx that fixed the problem not used to js i use c# :)
Answer by robertbu · Aug 16, 2013 at 04:40 PM
The error you are getting is often produce when the compiler is confused. Sometimes it is a missing semicolon, but often it is something else:
Line 38: this is a C# variable declaration. You want:
var spawnPosition : Vector3 = Camera.main.transform.position;
And the ': Vector3' is optional here since the compiler can figure out the type from the assignment.
Line 40: 'Value' should be 'value' with a lower case 'v'.
Line 44: You misspelled 'spawnPosition'.
Your answer
Follow this Question
Related Questions
insert semicolon error 3 Answers
Insert Semicolon error 1 Answer
insert a semicolon at the end?? 1 Answer
UCE0001 error Insert a Semicolon at end 1 Answer
Scripting error 1 Answer