void Awake() { // Register the singleton if (Instance != null) { Debug.LogError("Multiple instances of SoundScript!"); } Instance = this; DontDestroyOnLoad(transform.gameObject); }
// Use this for initialization void Start() { gameStateManager = GameObject.Find("GameStateManager"); gameStateScript = gameStateManager.GetComponent<GameStateScript>(); MainCamera = GameObject.Find("Main Camera"); BackgroundController = MainCamera.GetComponent<BackgroundController>(); MainGUI = MainCamera.GetComponent<MainGUI>(); JumpSoundObject = GameObject.Find("JumpSoundDumpster"); jumpSoundScript = JumpSoundObject.GetComponent<JumpSoundScript>(); PlayerLose = PlayerStart - 2; Lost = false; gameStateScript.Lost = false; gameStateScript.Won = false; gameStateScript.GameOver = false; }
void Update() { if (!dead && deathSensor.dead) { Death(); } //Вертикальная ось bool jumpKeyPressed = Input.GetKeyDown(KeyCode.Space); if (!dead && !isJumping && jumpKeyPressed && (jumpSensor.permissionToJump)) {//обеспечиваем анимацию и готовим и щелкаем триггер на прыжок isJumping = true; JumpSoundScript.SoundJump(); psDust.Stop(); animator.SetTrigger("Jump"); } if (isJumping) {//реализуем прыжок Jump(); } }