// Start contains code initializing the script variables, and is called before the first frame. void Start() { // Retrieve and store the player gameobject player = GameObject.Find("Player"); // Retrieve script attached to player GameObject playerController = player.GetComponent <PlayerController>(); // Retrieve and store the ScoreDetails gameobject scoreDetails = GameObject.Find("ScoreDetails"); // Retrieve script attached to ScoreDetails trickTrackController = scoreDetails.GetComponent <TrickTrackController>(); degInc = 6; }
// Start contains code initializing the script variables, and is called before the first frame void Start() { // Default speed is 10. speedDelta is 0 to ensure start speed is 0 speed = 10; speedDelta = 0; speedLimit = 146; PlayerPrefs.SetInt("Score", 0); // Initialize tail with reference to Tail GameObject, then get components with this reference tail = GameObject.Find("Tail"); tailController = tail.GetComponent <TailController>(); playerAnim = tail.GetComponent <Animator>(); // Get SplashController components of both splash objects, to use their methods to set splash positions splash1 = GameObject.Find("Splash1"); splash2 = GameObject.Find("Splash2"); splashController1 = splash1.GetComponent <SplashController>(); splashController2 = splash2.GetComponent <SplashController>(); // Again, get object reference followed by object component scoreDetails = GameObject.Find("ScoreDetails"); trickTrackController = scoreDetails.GetComponent <TrickTrackController>(); degrees = 0; degInc = 6; // Set acceleration and lenience based on difficulty difficulty = PlayerPrefs.GetInt("Difficulty"); switch (difficulty) { case 0: speedInc = 12; entryAngleLenience = 15; PlayerPrefs.SetFloat("end_multiplier", 1); break; case 1: speedInc = 10; entryAngleLenience = 35; break; case 2: speedInc = 8; entryAngleLenience = 25; break; case 3: speedInc = 6; entryAngleLenience = 15; break; case 4: speedInc = 5; entryAngleLenience = 10; break; } spaceObjects = new bool[10]; // Values for sea and sand boundary, and gravity gravConst = 0.3f; seaLevel = 20.5f; sandLevel = -44f; // Timer set to 25 so acceleration occurs at beginning timer = 25; maxTimer = 75; enterTimerSet1 = 5; enterTimerSet2 = 10; leftTouched = false; rightTouched = false; // Set all audio source variables to AudioSource components of respective GameObjects splash_source = GameObject.Find("Inside_Splash").GetComponent <AudioSource>(); outside_splash_source = GameObject.Find("Outside_Splash").GetComponent <AudioSource>(); underwater_ambience = GameObject.Find("Underwater_Ambience").GetComponent <AudioSource>(); outside_ambience = GameObject.Find("Outside_Ambience").GetComponent <AudioSource>(); space_ambience = GameObject.Find("Space_Ambience").GetComponent <AudioSource>(); outside_ambience.Play(); outside_ambience.volume = 0; }