Advertisement
NPSF3000

Cloned Explained

May 26th, 2011
241
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //Clone 10 objects.  Each X+2 away from the last.
  2.  
  3. static var already_cloned : bool = false;
  4.  
  5. //  Allow cloning once to prevent infinite cloning loop (as start is called on each clone!)
  6. function Start () {
  7.     //If we have already been cloned, early exit.
  8.     if (already_cloned) return;
  9.  
  10.     //If we haven't been cloned already
  11.         Clone();
  12.     already_cloned = true;
  13. }
  14.  
  15. function Clone(){
  16.     for (var i : int = 1;i <= 10; i++) {
  17.         Instantiate(
  18.                      gameObject,
  19.                  transform.position + Vector3(i * 2.0, 0, 0),
  20.                  Quaternion.identity
  21.                );
  22.     }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement