// Update is called once per frame void Update() { if (Physics.Raycast(transform.position, Vector3.down, out hit)) { if (hit.transform.tag == "SpawnWall") { boardScript script = hit.transform.GetComponent <boardScript>(); boards = script.boards; if (boards < 6) { Window = true; if (Input.GetKeyDown("e") && WaitingForRepair) { WaitingForRepair = false; hit.transform.SendMessage("Acknowledge", SendMessageOptions.DontRequireReceiver); StartCoroutine(Wait()); } } else { Window = false; } } else { Window = false; } } }
void OnCollisionExit(Collision collision) { Collider col = collision.collider; // wheel left ground if (col.tag == "wheel") { // get board instance ID int boardID = col.transform.parent.GetInstanceID(); // if no reference to this board exists in map, create it if (!boardMap.ContainsKey(boardID)) { // get board's boardscript reference boardScript bs = col.gameObject.GetComponentInParent(typeof(boardScript)) as boardScript; // add board and script to map boardMap.Add(boardID, bs); // Debug.Log("new board in map"); } // decrement number of wheels on ground for this board boardMap[boardID].UpdateWheelCount(-1); } }
void Start() { // obtain appropriate references for prefab children foreach (Transform child in gameObject.transform) { string childName = child.name; // boardScript contains information on trick attempt if (childName == "board") { boardScript = child.GetComponent <boardScript>(); // back foot rigidbody used to execute movements on back foot } else if (childName == "back_foot") { backFootRGBD = child.GetComponent <Rigidbody>(); backFootInitialPos = child.transform.position; boardScript.SetFoot(LEFT, child); // front foot rigidbody used to execute movements on front foot } else if (childName == "front_foot") { frontFootRGBD = child.GetComponent <Rigidbody>(); frontFootInitialPos = child.transform.position; boardScript.SetFoot(RIGHT, child); // fitness function designates how to interpret information } else if (childName == "fitnessFunctionObject") { fitnessFunction = child.GetComponent <FitnessFunction>(); } else { Debug.Log("Unknown child component " + child.name); } } // test ollie action pairs /* * actionsPairing = new Tuple<float, Vector3, bool>[]{ * Tuple.Create(0.9f, new Vector3(0.0f, 1.0f, 0.0f), RIGHT), * Tuple.Create(1f, new Vector3(0.0f, -2.0f, 0), LEFT), * Tuple.Create(1.05f, new Vector3(0.0f, 2.0f, 0.3f), LEFT), * Tuple.Create(1.05f, new Vector3(0.0f, 0.0f, 0.5f), RIGHT), * Tuple.Create(1.4f, new Vector3(0.0f, -2.0f, 0), LEFT), * Tuple.Create(1.4f, new Vector3(0.0f, -2.0f, -1.0f), RIGHT) * }; */ }
// Update is called once per frame void Update() { if (Physics.Raycast(transform.position, Vector3.down, out hit)) { if (hit.transform.tag == "SpawnWallZombieSide") { boardScript script = hit.transform.parent.gameObject.GetComponent <boardScript>(); boards = script.boards; print(boards); if (boards > 0 && !WaitingForNextBoard) { WaitingForNextBoard = true; RemoveBoard(hit.transform); } if (boards < 1) { print("happens"); nav.isStopped = false; Stopped = false; } } } }