private void Start()
    {
        GameObject check = GameObject.FindGameObjectWithTag("Poop");

        if (check != null)
        {
            poop = check.GetComponent <PoopIncrement>();
        }

        frontPL = GameObject.FindGameObjectWithTag("Player").GetComponent <Personaje>().frontCollider;
        backPL  = GameObject.FindGameObjectWithTag("Player").GetComponent <Personaje>().backCollider;

        //BUSCA LA REFERENCIA AL MATERIAL DEL PISO Y SU POSICION EN EL MESH
        Vector2    pos1 = Vector2.zero, pos2 = Vector2.zero;
        Ray        rayo = new Ray(this.init.position, Vector3.down);
        RaycastHit hit;
        LayerMask  mask = LayerMask.NameToLayer("Piso");

        if (Physics.Raycast(rayo, out hit, mask))
        {
            pos1 = hit.textureCoord;
        }
        rayo = new Ray(this.final.position, Vector3.down);
        if (Physics.Raycast(rayo, out hit, mask))
        {
            pos2 = hit.textureCoord;
        }
        GetInfo(pos1, pos2);
    }
Ejemplo n.º 2
0
 void ChooseCollider(FrontCollider currentColl)
 {
     poopRigid = currentColl.collide.attachedRigidbody;
     animBeetle.SetBool("holding", false);
     poopRigid.transform.SetParent(transform);
     poopRigid.isKinematic        = true;
     poopRigid.transform.position = currentColl.transform.position; //Pone en posicion el objeto
     movementSpeed = 5;
     rotationSpeed = 25;
 }