Пример #1
0
    // Update is called once per frame
    void Update()
    {
        if (!haveReceivedTipPosition)
        {
            Vector3 posTip2;
            bool    result = FalconUnity.getTipPosition(falcon_num, out posTip2);
            if (!result)
            {
//				Debug.Log("Error getting tip position");
                return;
            }
            receivedCount++;

            if (receivedCount < 25 && (posTip2.x == 0 && posTip2.y == 0 && posTip2.z == 0))
            {
                return;
            }

            hapticTip.position = posTip2;

            godObject.position = posTip2;

            Debug.Log("Initialized with tip position: ");
            Debug.Log(posTip2);
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);

            haveReceivedTipPosition = true;
        }

        Vector3 tipPositionScale = new Vector3(1, 1, -1);

        tipPositionScale *= hapticTipToWorldScale;

        if (savedHapticTipToWorldScale != hapticTipToWorldScale)
        {
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
            savedHapticTipToWorldScale = hapticTipToWorldScale;
        }

        FalconUnity.updateHapticTransform(falcon_num, transform.position, transform.rotation, tipPositionScale, useMotionCompensator, Time.deltaTime);

        Vector3 posGod;
        bool    res = FalconUnity.getGodPosition(falcon_num, out posGod);

        if (!res)
        {
//			Debug.Log("Error getting god tip position");
            return;
        }
        Vector3 posTip;

        res = FalconUnity.getTipPosition(falcon_num, out posTip);
        if (!res)
        {
//			Debug.Log("Error getting tip position");
            return;
        }
        hapticTip.position = posTip;

        godObject.position = posGod;
        godObject.rotation = new Quaternion(0, 0, 0, 1);

        FalconUnity.setForceField(falcon_num, constantforce + TurretForce);
    }
    // Update is called once per frame
    void Update()
    {
        if (contador.b_instanciar == 0)
        {
            aux1 = 0;
        }
        if (contador.b_instanciar == 0 && aux2 == 0)
        {
            aux2 = 1;
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
        }


        if (contador.b_instanciar == 1 && aux1 == 0)
        {
            aux  = 0;
            aux2 = 0;
        }


        if (aux == 0)
        {
            FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
            aux  = 1;
            aux1 = 1;
            aux2 = 0;
        }


        num_falcons = FalconUnity.getNumFalcons();
        FalconUnity.Update();



        if (contador.ganador_consultorio == 0)
        {
            if (!haveReceivedTipPosition)
            {
                Vector3 posTip2;
                bool    result = FalconUnity.getTipPosition(falcon_num, out posTip2);
                if (!result)
                {
                    //				Debug.Log("Error getting tip position");
                    return;
                }
                receivedCount++;

                if (receivedCount < 25 && (posTip2.x == 0 && posTip2.y == 0 && posTip2.z == 0))
                {
                    return;
                }

                //hapticTip.position = posTip2;

                //godObject.position = posTip2;
                hapticTip.position = new Vector3(posTip2.x, posTip2.y, posTip2.z);//posTip2.z

                godObject.position = new Vector3(posTip2.x, posTip2.y, posTip2.z);

                Debug.Log("Initialized with tip position: ");
                Debug.Log(posTip2);
                FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);

                haveReceivedTipPosition = true;
            }

            Vector3 tipPositionScale = new Vector3(1, 1, -1);
            tipPositionScale *= hapticTipToWorldScale;

            if (savedHapticTipToWorldScale != hapticTipToWorldScale)
            {
                FalconUnity.setSphereGodObject(falcon_num, godObject.localScale.x * godObject.GetComponent <SphereCollider>().radius, godObjectMass, godObject.position, minDistToMaxForce * hapticTipToWorldScale, maxDistToMaxForce * hapticTipToWorldScale);
                //FalconUnity.updateDynamicShape(contador.cuerpo, 0.001f, 0.01f,godObject.transform.localScale, new Vector3(0, 0, 0), 0.8f);
                savedHapticTipToWorldScale = hapticTipToWorldScale;
            }

            FalconUnity.updateHapticTransform(falcon_num, new Vector3(transform.position.x, transform.position.y, 0), transform.rotation, tipPositionScale, useMotionCompensator, Time.deltaTime);

            Vector3 posGod;
            bool    res = FalconUnity.getGodPosition(falcon_num, out posGod);
            if (!res)
            {
                //			Debug.Log("Error getting god tip position");
                return;
            }
            Vector3 posTip;
            res = FalconUnity.getTipPosition(falcon_num, out posTip);
            if (!res)
            {
                //			Debug.Log("Error getting tip position");
                return;
            }
            hapticTip.position = posTip;

            godObject.position = posGod;
            // manito.position = posGod;

            godObject.rotation = new Quaternion(0, 0, 0, 1);

            camara.position = godObject.position;
        }
        else
        {
        }
    }