Example #1
0
 void FixedUpdate()
 {
     if (tag == "MekaGear")
     {
         if (!target.activeSelf)
         {
             target = GameObject.FindGameObjectWithTag("Enemy");
         }
         direction = target.transform.position - transform.position;
     }
     transform.position += direction * speed * Time.deltaTime;
     transform.rotation  = MathK.LookAngle(direction);
 }
Example #2
0
 void Move()
 {
     if (target == null)
     {
         transform.position += vecMove.normalized * moveSpeed * Time.deltaTime;
         transform.rotation  = MathK.LookAngle(vecMove);
     }
     else
     {
         if (target.activeSelf)
         {
             transform.position = Vector3.Lerp(transform.position, target.transform.position, 10f * Time.deltaTime);
             transform.rotation = MathK.LookAngle(target.transform.position - transform.position);
         }
         else
         {
             target = null;
         }
     }
 }