Ejemplo n.º 1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "DigSpot")
     {
         Debug.Log("colliding with digspot");
         DigSpot check = other.GetComponent <DigSpot>();
         if (check)
         {
             check.Use();
         }
         else
         {
             DigSpot_Grave check2 = other.GetComponent <DigSpot_Grave>();
             check2.Use();
         }
     }
     else if (other.tag == "GraveEntrance")
     {
         other.GetComponent <GraveEntrance>().Use();
         Die();
     }
 }
Ejemplo n.º 2
0
    IEnumerator begindig()
    {
        anim.SetFloat("Blend", 2);
        rb.constraints = RigidbodyConstraints2D.FreezeAll;
        yield return(new WaitForSeconds(1));

        Collider2D[] colliders = Physics2D.OverlapCircleAll(transform.position, 1f);

        foreach (Collider2D near in colliders)
        {
            DigSpot dig = near.GetComponent <DigSpot>();
            if (dig != null && dig.dug == false)
            {
                //Instantiate(dig.obj, dig.transform.position, Quaternion.identity);
                dig.spawn();
                dig.dug    = true;
                currTarget = transform;
            }
        }
        startDig       = false;
        rb.constraints = RigidbodyConstraints2D.None;
        rb.constraints = RigidbodyConstraints2D.FreezeRotation;
    }