In unity, using C#, i'm calling the SwitchState() function from the Update(), but what's…
- User
In unity, using C#, i'm calling the SwitchState() function from the Update(), but what's wrong with the SwitchState() function?
void Update(){ SwitchState();}
void SwitchState() { if (healthSlider.value <= 0 && !isDead) { isDead = true; beautify.sepiaIntensity = 1f; StartCoroutine(CharacterDeath()); }
else if (healthSlider.value > 0 && healthSlider.value < (Health / 5.5f)) { beautify.sepiaIntensity = 1f; isInjured = true; } else if (healthSlider.value > (Health / 5.5f) && healthSlider.value < (Health / 4)) { beautify.sepiaIntensity = 0.90f; isInjured = true; } else if (healthSlider.value > (Health / 4) && healthSlider.value < (Health / 2)) { beautify.sepiaIntensity = 0.65f; isInjured = true; } else if (healthSlider.value > (Health / 2) && healthSlider.value < (Health / 1.3f)) { beautify.sepiaIntensity = 0.35f; isInjured = false; } else if (healthSlider.value > (Health / 1.3f)) { beautify.sepiaIntensity = 0f; isInjured = false; } if (isInjured && !isDead && !isSuiciding) { if (woundedPoseRig != null && shotgun.activeInHierarchy == true) { woundedPoseRig.weight = 1f; } m_Animator.SetBool("isInjured", true); BloodScreenFx.SetBool("50Health", true); BloodScreenFx.SetBool("100Health", false); if (Time.time - timePainSoundPlayed < 4f) return; HeartbeatAudioSource.clip = Heartbeat; HeartbeatAudioSource.Play(); int n = Random.Range(1, Painsounds.Length); AudioClip painSounds = Painsounds[n]; if (!audioSource.isPlaying) { audioSource.PlayOneShot(painSounds); Painsounds[n] = Painsounds[0]; Painsounds[0] = painSounds; timePainSoundPlayed = Time.time; } } if (!isInjured || isDead || isSuiciding) { if (woundedPoseRig != null && shotgun.activeInHierarchy == true) { woundedPoseRig.weight = 0f; } m_Animator.SetBool("isInjured", false); BloodScreenFx.SetBool("50Health", false); BloodScreenFx.SetBool("100Health", true); HeartbeatAudioSource.clip = Heartbeat; HeartbeatAudioSource.Stop(); } } - Assistant
- User
Improve the script
- Assistant