void Start() { //Debug.Log ("GC start cell"); //options = GameObject.Find("Canvas").GetComponent<Options>(); Transform parent = this.transform.parent; MonoBehaviour[] components = parent.GetComponents <MonoBehaviour>(); for (int i = 0; i < components.Length; i++) { Debug.Log(components.ToString()); } int children = parent.childCount; //Debug.Log("GC child count: " + children); box = parent.GetComponent <BoxCollider>(); GameObject boardObject = GameObject.Find("GenericBoard"); if (boardObject != null) { board = GameObject.Find("GenericBoard").GetComponent <GenericBoard>(); } else { //Debug.Log ("GC there is no board"); } //Debug.Log ("GC end start cell"); SpecificStart(); }
// Start is called before the first frame update void Start() { Time.fixedDeltaTime = PlayerPrefs.GetFloat("DeltaTime"); Board0 = gameObject.AddComponent <GenericBoard>(); Board1 = gameObject.AddComponent <GenericBoard>(); Board2 = gameObject.AddComponent <GenericBoard>(); Board3 = gameObject.AddComponent <GenericBoard>(); Wii.StartSearch(); Wii.WakeUp(); Boards.Add(Board0); Boards.Add(Board1); Boards.Add(Board2); Boards.Add(Board3); Board0.BoardNumber = 0; Board1.BoardNumber = 1; Board2.BoardNumber = 2; Board3.BoardNumber = 3; updatetime = 0.02F; Board0.RotationAngle = PlayerPrefs.GetFloat("Board0_angle"); Board1.RotationAngle = PlayerPrefs.GetFloat("Board1_angle"); Board2.RotationAngle = 0; Board3.RotationAngle = 0; Board0.Board_length = PlayerPrefs.GetFloat("Board_Length"); Board0.Board_width = PlayerPrefs.GetFloat("Board_Width"); Board1.Board_length = PlayerPrefs.GetFloat("Board_Length"); Board1.Board_width = PlayerPrefs.GetFloat("Board_Width"); Board2.Board_length = PlayerPrefs.GetFloat("Board_Length"); Board2.Board_width = PlayerPrefs.GetFloat("Board_Width"); Board3.Board_length = PlayerPrefs.GetFloat("Board_Length"); Board3.Board_width = PlayerPrefs.GetFloat("Board_Width"); Board0.BoardPosition.Set(0f, 0f); Board1.BoardPosition.Set(PlayerPrefs.GetFloat("Board1_x"), PlayerPrefs.GetFloat("Board1_y")); Board0.Board_Force_error_storage.Set(0.0f, 0.0f, 0.0f, 0.0f); Board1.Board_Force_error_storage.Set(0.0f, 0.0f, 0.0f, 0.0f); foreach (GenericBoard item in Boards) { // Calculate Initial Sensor Position item.SensorXRelative.x = Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length - Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorXRelative.y = Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length + Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorYRelative.x = -Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length - Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorYRelative.y = -Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length + Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorZRelative.x = Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length + Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorZRelative.y = Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length - Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorWRelative.x = -Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length + Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorWRelative.y = -Mathf.Sin(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_length - Mathf.Cos(Mathf.Deg2Rad * item.RotationAngle) * 1 / 2 * item.Board_width; item.SensorXinGlobal = item.BoardPosition + item.SensorXRelative; item.SensorYinGlobal = item.BoardPosition + item.SensorYRelative; item.SensorZinGlobal = item.BoardPosition + item.SensorZRelative; item.SensorWinGlobal = item.BoardPosition + item.SensorWRelative; } }
public Vector4 EliminateError(GenericBoard inputboard) { inputboard.CalibratedForce.x = inputboard.Board_Force.x - inputboard.Board_Force_error_storage.x; inputboard.CalibratedForce.y = inputboard.Board_Force.y - inputboard.Board_Force_error_storage.y; inputboard.CalibratedForce.z = inputboard.Board_Force.z - inputboard.Board_Force_error_storage.z; inputboard.CalibratedForce.w = inputboard.Board_Force.w - inputboard.Board_Force_error_storage.w; return(inputboard.CalibratedForce); }