Advertisement
Guest User

Problem

a guest
Dec 19th, 2013
237
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. void ALIVE_EnterState()
  2.     {
  3.         for(int fs = 0; fs < health; ++fs)
  4.         {
  5.             Debug.Log("Made a Heart!");
  6.             int fsp = (fs % DEFAULT_HEALTHPERROW);
  7.             int fsz = (int)Mathf.Floor(fs / DEFAULT_HEALTHPERROW);
  8.  
  9.             float posX = camera.transform.position.x + (-HEALTH_X + (fsp * DEFAULT_HEALTHOFFSET));
  10.             float posY = camera.transform.position.y + (-HEALTH_Y + (fsz * DEFAULT_HEALTHOFFSET));
  11.  
  12.             Vector3 position = new Vector3(posX, posY, 0);
  13.  
  14.             GameObject heart = (GameObject)GameObject.Instantiate(healthSpritePrefab, position, Quaternion.identity); // GameObject(Clone) is created
  15.             heart.name = "Heart "+fs;
  16.  
  17.             if(heart == null)
  18.             {
  19.                 Debug.Log("Couldnt Create Heart :(");
  20.             }
  21.             else
  22.             {
  23.                 heart.transform.parent = camera.transform;
  24.                 healthSprites.Add(heart); // Added to an List
  25.             }
  26.         }
  27.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement