Ejemplo n.º 1
0
 void Update()
 {
     //Kill yo self
     if (curHP <= 0)
     {
         creatureHPBar.Destroy();
         Destroy(self);
     }
     //Don't do move things if computer has the dumb
     if (!runAI)
     {
         return;
     }
     //My "AI", basically spaz back and forth based on randomness.
     if (new System.Random().Next(2) == 0)
     {
         self.GetComponent <Collider2D>().GetComponent <Rigidbody2D>().AddForce(new Vector2(-20, 0), ForceMode2D.Force);
     }
     else
     {
         self.GetComponent <Collider2D>().GetComponent <Rigidbody2D>().AddForce(new Vector2(20, 0), ForceMode2D.Force);
     }
 }