I would like to load a new level when the playerScore reaches 20. I’ve been using if statements followed by load level but they’re not working. Could someone take a look at the script and tell me what I should be doing?
Blockquote
var cSpeed:float = 10.0;
var sFactor:float = 10.0;
//Two variables to hold our scores
static var playerScore:int = 0;
static var enemyScore:int = 0;
function Start ()
{
rigidbody.AddForce(10,1.5,0);
}
function Update ()
{
var cvel = rigidbody.velocity;
var tvel = cvel.normalized * cSpeed;
rigidbody.velocity = Vector3.Lerp(cvel,tvel,Time.deltaTime * sFactor);
//Check the right bounds
if(transform.position.x > 24)
{
playerScore++;
transform.position.x = 0;
transform.position.y = 0;
}
//Check the left bounds
if(transform.position.x < -24)
{
enemyScore++;
transform.position.x = 0;
transform.position.y = 0;
}
}