Example #1
0
 void Update()
 {
     if (asteroid == null && !hadTarget)
     {
         asteroid  = commonProc.findClosestGameObject(this.gameObject, "Enemy");
         hadTarget = true;
     }
     if (asteroid != null && !attached)
     {
         attached = commonProc.trackToObject(body, asteroid, 10f, true);
     }
     else if (asteroid != null && attached)
     {
         Rigidbody2D aBody = asteroid.GetComponent <Rigidbody2D>();
         body.angularVelocity = aBody.angularVelocity;
         body.velocity        = aBody.velocity;
     }
     else if (hadTarget)
     {
         Destroy(this.gameObject);
     }
 }