// Update is called once per frame void Update() { if (activable.isClosing() || activable.isOpening()) { fitness_temp = time_fitness_temp_sound; if (soundParticleSystem == null) { soundParticleSystem = Instantiate(Global.soundEffect, hiddingPlace.transform.position, Quaternion.identity); } } if (fitness_temp > 0) { fitness_temp -= Time.deltaTime; } else if (fitness_temp < 0) { fitness_temp = 0; } if (soundParticleSystem != null && fitness_temp == 0) { Destroy(soundParticleSystem); } }
// Update is called once per frame public void Update() { if (activable != null) { if (!added && (activable.isClosing() || activable.isOpening())) // Si la porte du placard bouge { fitness_temp += fitness_temp_sound; added = true; if (instanceOfSoundEffect == null) { instanceOfSoundEffect = UnityEngine.Object.Instantiate(Global.soundEffect, target.transform.position, Quaternion.identity); } } else { added = false; } } if (fitness_temp > 0) { fitness_temp -= Time.deltaTime; } if (fitness_temp <= 0) { fitness_temp = 0; if (instanceOfSoundEffect != null) { UnityEngine.Object.Destroy(instanceOfSoundEffect); } } }
// Update is called once per frame void Update() { isEnable = activable.isOpened(); if (isEnable != prev_state) { EnableLight(gameObject, isEnable); EnableLightMesh(gameObject, isEnable); prev_state = isEnable; } if (activable.isClosing() && soundOff != null && !soundOff.IsPlaying()) { soundOff.Play(); } if (activable.isOpening() && soundOn != null && !soundOn.IsPlaying()) { soundOn.Play(); } }
// Update is called once per frame void Update() { if (playerController == null) { playerController = GameObject.Find("Server_FPS(Clone)"); } if (timeActual < timeBeforeNextAction) { timeActual += Time.deltaTime; } if ((activable.isOpened() || activable.isClosing()) && timeActual >= timeBeforeNextAction && playerController != null) { if (nobodyInside) { _camera.transform.position = m_camera.transform.position; _camera.transform.rotation = m_camera.transform.rotation; playerController.GetComponent <MoveFPS> ().enabled = false; previousPosition = playerController.transform.position; playerController.transform.position = m_camera.transform.position - Vector3.up * 0.5f; playerController.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f); } else { playerController.transform.position = previousPosition; playerController.GetComponent <MoveFPS> ().enabled = true; playerController.transform.localScale = new Vector3(1f, 1f, 1f); } nobodyInside = !nobodyInside; timeActual = 0.0f; } }