IEnumerator FallThroughtInvincibility() { damageable.EnableInvulnerability(true); yield return(new WaitForSeconds(0.5f)); damageable.DisableInvulnerability(); }
public void OnHurt(TakeDamager damager, TakeDamageable damageable) { //if the player don't have control, we shouldn't be able to be hurt as this wouldn't be fair if (!PlayerInput.Instance.HaveControl) { return; } UpdateFacing(damageable.GetDamageDirection().x > 0f); damageable.EnableInvulnerability(); m_Animator.SetTrigger(m_HashHurtPara); //we only force respawn if health > 0, otherwise both forceRespawn & Death trigger are set in the animator, messing with each other. if (damageable.CurrentHealth > 0 && damager.forceRespawn) { m_Animator.SetTrigger(m_HashForcedRespawnPara); } m_Animator.SetBool(m_HashGroundedPara, false); hurtAudioPlayer.PlayRandomSound(); //if the health is < 0, mean die callback will take care of respawn if (damager.forceRespawn && damageable.CurrentHealth > 0) { //StartCoroutine(DieRespawnCoroutine(false, true)); } }