void Start() { //Cache myTransform = transform; myCollider = collider; runner = GameObject.FindGameObjectWithTag ("Player"); spawner = GameObject.FindGameObjectWithTag ("Spawner").GetComponent<SpawnObstacles> (); topBorder = GameObject.FindGameObjectWithTag("Top"); bottomBorder = GameObject.FindGameObjectWithTag("Bottom"); runnerScore = GameObject.FindGameObjectWithTag ("Score").GetComponent<RunnerScoring>(); runnerScoreMulti = GameObject.FindGameObjectWithTag ("ScoreMulti").GetComponent<RunnerScoringMulti>(); //Positioning initialization if(gameObject.CompareTag("BottomGate")) { speedVarBottomTop = speedVar * Random.Range(0.2f, 0.4f); myTransform.position = new Vector3 (590.0f, bottomBorder.collider.bounds.max.y, 0.0f); } if(gameObject.CompareTag("TopGate")) { speedVarBottomTop = speedVar * Random.Range(0.2f, 0.4f); myTransform.position = new Vector3 (590.0f, topBorder.collider.bounds.min.y, 0.0f); } if(gameObject.CompareTag("CenterGate")) { myTransform.position = new Vector3 (590.0f, 0.0f, 0.0f); } if(gameObject.CompareTag("regGate")) { myTransform.position = new Vector3 (590.0f, topBorder.collider.bounds.min.y - myCollider.bounds.extents.y, 0.0f); } if(gameObject.CompareTag("MovingGate")) { myTransform.position = new Vector3 (590.0f, myTransform.position.y, 0.0f); myTransform.localScale = new Vector3(myTransform.localScale.x, Random.Range(100, 250), myTransform.localScale.z); speedVarMovingGate = speedVar * Random.Range(0.5f, 0.7f); if (Random.Range (0, 2) == 1 ) { speedVarMovingGate *= -1; } } //Scoring initialization allowScoreOnPass = true; }
void Start() { //Object access pMovement = gameObject.GetComponent<RunnerScript> (); myTransform = transform; collisionBoundOffset = pMovement.collider.bounds.size.y / 4.0f; score = GameObject.FindGameObjectWithTag("Score").GetComponent<RunnerScoring>(); scoreMulti = GameObject.FindGameObjectWithTag("ScoreMulti").GetComponent<RunnerScoringMulti>(); detector = GameObject.FindGameObjectWithTag("Recognizer").GetComponent<TapDetector>(); spawner = GameObject.FindGameObjectWithTag("Spawner").GetComponent<SpawnObstacles>(); myBonusBehaviorDown = GameObject.FindGameObjectWithTag("BonusDown").GetComponent<BonusDownBehavior>(); //Respawn variables respawn = false; gameRestart = false; //Scoring & bonus allowScoring = true; allowScoringMultiplier = true; allowBonusDown = true; numGatesHit = 0; //Camera control myCamera = GameObject.FindGameObjectWithTag ("MainCamera"); //Acheivement variables closeCallStart = false; closeCallEnd = false; }