Ejemplo n.º 1
0
 /// <summary>
 /// Sends the received packets to the active robot
 /// </summary>
 private void SendRobotPackets()
 {
     activeRobot.Packet = unityPacket.GetLastPacket();
     foreach (Robot robot in SpawnedRobots)
     {
         if (robot != activeRobot)
         {
             robot.Packet = new UnityPacket.OutputStatePacket();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Sends the received packets to the active robot
 /// </summary>
 private void SendRobotPackets()
 {
     ActiveRobot.Packet = unityPacket.GetLastPacket();
     foreach (SimulatorRobot robot in SpawnedRobots)
     {
         if (robot != ActiveRobot)
         {
             robot.Packet = null;
         }
     }
 }
Ejemplo n.º 3
0
    void FixedUpdate()
    {
        if (Input.GetKey(KeyCode.M))
        {
            SceneManager.LoadScene("MainMenu");
        }

        if (rootNode != null)
        {
            UnityPacket.OutputStatePacket packet = unityPacket.GetLastPacket();

            DriveJoints.UpdateAllMotors(rootNode, packet.dio);
        }

        BRigidBody rigidBody = robotObject.GetComponentInChildren <BRigidBody>();

        if (Input.GetKey(KeyCode.R))
        {
            if (!resetting)
            {
                foreach (GameObject g in extraElements)
                {
                    Destroy(g);
                }

                BeginReset();

                resetting = true;
            }

            Vector3 transposition = new Vector3(
                Input.GetKey(KeyCode.RightArrow) ? RESET_VELOCITY : Input.GetKey(KeyCode.LeftArrow) ? -RESET_VELOCITY : 0f,
                0f,
                Input.GetKey(KeyCode.UpArrow) ? RESET_VELOCITY : Input.GetKey(KeyCode.DownArrow) ? -RESET_VELOCITY : 0f);

            if (!transposition.Equals(Vector3.zero))
            {
                TransposeRobot(transposition);
            }
        }
        else
        {
            EndReset();

            resetting = false;
        }

        if (!rigidBody.GetCollisionObject().IsActive)
        {
            rigidBody.GetCollisionObject().Activate();
        }
    }