Here is what I have currently:
http://dl.dropbox.com/u/43867531/Dungeon%20Escape/WebPlayer/WebPlayer.html
Here is the script:
var currentBlock : GameObject;
var Lava : GameObject;
var Stone : GameObject;
var randomMax : int = 150;
var difficulty : int = 150;
var generatedInt : int;
var generatedInt2 : int;
var player : GameObject;
var lastBlockX : GameObject;
function Start ()
{
yield StartCoroutine("GenerateNumbers");
}
function Update ()
{
if(Vector3.Distance(player.transform.position, lastBlockX.transform.position) < 5)
{
Generate();
}
print ( generatedInt );
}
function Generate ()
{
var nextPosX : Vector3 = new Vector3(lastBlockX.transform.position.x + 0.5, lastBlockX.transform.position.y,lastBlockX.transform.position.z);
newBlockX = Instantiate(currentBlock, nextPosX, lastBlockX.transform.rotation);
lastBlockX = newBlockX;
if ( generatedInt <= difficulty )
{
currentBlock = Lava;
}
if ( generatedInt >= difficulty )
{
currentBlock = Stone;
}
}
function GenerateNumbers ()
{
while(true)
{
yield WaitForSeconds(0.25);
generatedInt = Random.Range(0,randomMax);
}
}
Anyways, The orange blocks are lava. I am trying to get it to generate lava randomly, but it is generating them in strings that are too long. How would I solve this?