Skip to content

Instantly share code, notes, and snippets.

@Gojeflone
Created February 17, 2014 02:30
Show Gist options
  • Save Gojeflone/9043701 to your computer and use it in GitHub Desktop.
Save Gojeflone/9043701 to your computer and use it in GitHub Desktop.
For loops in Unity
var myPrefab : Rigidbody;
var distanceMultiplier : float = 2;
function Start(){
var i : int = 0;
var pos : Vector3 = transform.position;
for(i=0; i<=3; i++){
Instantiate(myPrefab, Vector3(pos.x+i*distanceMultiplier, pos.y, pos.z), transform.rotation);
yield WaitForSeconds(0.5);
Debug.Log("made ball "+i);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment