// Use this for initialization void Start() { // Get animator. anim = GetComponent <Animator>(); // Get rigid body. rigidBody = GetComponent <Rigidbody>(); // Get audio source. audioSource = GetComponent <AudioSource>(); // Get obstacle tag. obstacleTag = ConstantsManager.GetTag(ObjectTags.obstacle); // Get jump animation name. jumpAnimationName = ConstantsManager.GetAnimationName(Animations.jump); // Play jump animation. anim.Play(ConstantsManager.GetAnimationName(Animations.fly)); }
private void SetAfterPlayerCollidedState() { /// Set main menu state. MenuManager.instance.Game(GameState.replayScreen); /// Show main menu. mainMenu.SetActive(true); /// Show main menu. mainMenuPrefab.SetActive(true); /// Hide scene GUI. sceneGUI.SetActive(false); /// Reset rock position. GameObject obstacle = GameObject.FindGameObjectWithTag(ConstantsManager.GetTag(ObjectTags.obstacle)); if (obstacle != null) { Rock rockScript = obstacle.GetComponent <Rock>(); if (rockScript != null) { /// Get random starting position coordinates. float randomX = Random.Range(3.75f, 4.0f); float randomY = Random.Range(2.0f, 8.0f); /// Set new starting position. rockScript.setStart(new Vector3(randomX, randomY, -3.2f)); } } /// Destroy player prefab. Destroy(player); /// Destroy hit smoke effect. Destroy(hitSmokeEffect); /// Destroy scene prefab. Destroy(currentScene); }