void Start() { m_collider = GetComponent <Collider>(); // m_cubeMeshRenderer = transform.Find("Cube").gameObject.GetComponent<MeshRenderer>(); m_cubeMeshRenderer = subCube.GetComponent <MeshRenderer>(); m_scoreZoneSimSceneManager = GameObject.Find("StateMachine").GetComponent <ScoreZoneSimSceneManager>(); m_dpmRobot = GameObject.Find("StateMachine").GetComponent <DriverPracticeMode>().dpmRobot; m_dpm = GameObject.Find("StateMachine").GetComponent <DriverPracticeMode>(); this.GetComponent <BBoxShape>().Extents = transform.localScale * 0.5f; }
/// <summary> /// Called after Awake() when the script instance is enabled. /// Initializes variables then loads the field and robot as well as setting up replay features. /// </summary> public override void Start() { AppModel.ClearError(); //getting bullet physics information physicsWorld = BPhysicsWorld.Get(); ((DynamicsWorld)physicsWorld.world).SetInternalTickCallback(BPhysicsTickListener.Instance.PhysicsTick); lastFrameCount = physicsWorld.frameCount; //setting up raycast robot tick callback BPhysicsTickListener.Instance.OnTick += BRobotManager.Instance.UpdateRaycastRobots; //setting up replay CollisionTracker = new CollisionTracker(this); //starts a new instance of unity packet which receives packets from the driver station unityPacket = new UnityPacket(); unityPacket.Start(); //loads all the controls Controls.Load(); //If a replay has been selected, load the replay. Otherwise, load the field and robot. string selectedReplay = PlayerPrefs.GetString("simSelectedReplay"); SpawnedRobots = new List <Robot>(); if (string.IsNullOrEmpty(selectedReplay)) { Tracking = true; fieldPath = PlayerPrefs.GetString("simSelectedField"); robotPath = PlayerPrefs.GetString("simSelectedRobot"); Debug.Log(RobotFieldLoader.LoadField(fieldPath) ? "Load field success!" : "Load field failed."); Debug.Log(LoadRobot(robotPath) ? "Load robot success!" : "Load robot failed."); if (!LoadRobot(PlayerPrefs.GetString("simSelectedRobot"))) { AppModel.ErrorToMenu("Could not load robot: " + PlayerPrefs.GetString("simSelectedRobot") + "\nHas it been moved or deleted?)"); return; } int isMixAndMatch = PlayerPrefs.GetInt("mixAndMatch", 0); // 0 is false, 1 is true int hasManipulator = PlayerPrefs.GetInt("hasManipulator"); if (isMixAndMatch == 1 && hasManipulator == 1) { Debug.Log(LoadManipulator(PlayerPrefs.GetString("simSelectedManipulator")) ? "Load manipulator success" : "Load manipulator failed"); } } else { awaitingReplay = true; LoadReplay(selectedReplay); } //initializes the dynamic camera dynamicCameraObject = GameObject.Find("Main Camera"); dynamicCamera = dynamicCameraObject.AddComponent <DynamicCamera>(); DynamicCamera.MovingEnabled = true; sensorManager = GameObject.Find("SensorManager").GetComponent <SensorManager>(); sensorManagerGUI = GameObject.Find("StateMachine").GetComponent <SensorManagerGUI>(); robotCameraManager = GameObject.Find("RobotCameraList").GetComponent <RobotCameraManager>(); ScoreZoneSimSceneManager scoreZoneSimSceneManager = GameObject.Find("StateMachine").GetComponent <ScoreZoneSimSceneManager>(); scoreZoneSimSceneManager.LoadScoreZones(); }