Ejemplo n.º 1
0
    private void Charge()
    {
        GameObject a = AvatarRespawner.Instance.Avatar;

        if (a != null)
        {
            Debug.Log("Charging");
            moveScript.Move(VectorFunc.ConvertTo2DVec(a.transform.position - transform.position), moveSpeed);
        }
    }
 public void Move(Vector2 direction, float speed)
 {
     direction.Normalize();
     if (rb != null)
     {
         Vector2 currentPos = VectorFunc.ConvertTo2DVec(transform.position);
         Debug.DrawRay(currentPos, direction, Color.blue);
         Debug.Log((direction * speed * Time.deltaTime).magnitude);
         rb.position = (currentPos + direction * speed * Time.deltaTime);
     }
     else
     {
         transform.Translate(direction * speed * Time.deltaTime, Space.World);
     }
 }
Ejemplo n.º 3
0
 private bool AvatarInRange()
 {
     return(AvatarRespawner.Instance.Avatar != null &&
            Vector2.Distance(VectorFunc.ConvertTo2DVec(AvatarRespawner.Instance.Avatar.transform.position), VectorFunc.ConvertTo2DVec(transform.position)) < aggroDistance);
 }