// Update is called once per frame void Update() { if (my_num == 0) { num_falcons = FalconUnity.getNumFalcons(); FalconUnity.Update(); } }
void Start() { // FalconUnity.setForceField(0, new float[] {0,-10,0}); if (my_num == 0) { num_falcons = FalconUnity.getNumFalcons(); if (FalconUnity.IsRemote()) { FalconUnity.Update(); } } }
// Use this for initialization void Awake() { my_num = getNextNum(); if (my_num == 0) { Debug.Log(address + " " + port); FalconUnity.setServerParams(address, port); FalconUnity.Start(); FalconUnity.Update(); if (FalconUnity.IsRemote()) { FalconUnity.Update(); } FalconUnity.setGravity(gravity); } }
// Update is called once per frame void Update() { num_falcons = FalconUnity.getNumFalcons(); FalconUnity.Update(); if (contador.fuerza == 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); 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); // FalconUnity.setForceField(falcon_num,force); } else { Debug.Log("notomaposicion"); } }
// 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 { } }