Example #1
0
 void Move()
 {
     if (target != null)
     {
         if (Vector2.Distance(transform.position, target.position) < .1f)
         {
             tempEnemy.TakeDemage(selfBullet.demage);
             Destroy(gameObject);
         }
         else
         {
             Vector2 dir = target.position - transform.position;
             transform.Translate(dir.normalized * Time.deltaTime * selfBullet.speed);
         }
     }
     else
     {
         Destroy(gameObject);
     }
 }