Пример #1
0
    void Agarrar(CodigoGenetico codigo)
    {
        // if (agarre) Destroy(agarre);
        cabezaAgarrada = codigo;

        if (AgarreJoint && codigo && codigo.Rigid)
        {
            cabezaAgarrada.Agarrada   = true;
            AgarreJoint.connectedBody = codigo.Rigid;
        }
    }
 IEnumerator ReiniciarAlCaer(CodigoGenetico gen)
 {
     while (gen)
     {
         if (gen.transform.position.y < limiteYCaida)
         {
             gen.Rigid.velocity     = Vector3.zero;
             gen.transform.position = posSaleGenes.transform.position;
             gen.GenForm();
         }
         yield return(new WaitForSeconds(.3f));
     }
 }
Пример #3
0
 void Soltar()
 {
     if (watchCam)
     {
         watchCam.transform.position = watchCamOriginalPos;
         watchCam.transform.rotation = watchCamOriginalRot;
     }
     if (AgarreJoint)
     {
         if (cabezaAgarrada)
         {
             cabezaAgarrada.Agarrada = false;
         }
         AgarreJoint.connectedBody = null;
         cabezaAgarrada            = null;
     }
 }
Пример #4
0
    void Update()
    {
        if (cabezaAgarrada)
        {
            if (!Input.GetMouseButton(0))
            {
                Soltar();
            }
        }
        else
        {
            var rayo = Camera.main.ScreenPointToRay(Input.mousePosition);

            RaycastHit hits;
            if (Physics.Raycast(rayo, out hits, 1000, mascaraAgarre, QueryTriggerInteraction.Collide))
            {
                cabezaApuntada = hits.transform.GetComponentInParent <CodigoGenetico>();
            }
            else
            {
                cabezaApuntada = null;
            }

            if (watchCam)
            {
                if (cabezaApuntada)
                {
                    watchCam.transform.position = cabezaApuntada.CabPropiaTransform.TransformPoint(watchCamDist);
                    watchCam.transform.rotation = cabezaApuntada.CabPropiaTransform.rotation * Quaternion.Euler(0, 180, 0);
                }
                else
                {
                    watchCam.transform.position = watchCamOriginalPos;
                    watchCam.transform.rotation = watchCamOriginalRot;
                }
            }

            if (Input.GetMouseButtonDown(0))
            {
                Agarrar(cabezaApuntada);
            }
        }
    }