// Runs when object is hit with player weapon public void TakeDamage(Vector3 hitPosition, float duration, float power) { m_KnockbackTime = duration; Vector3 vec = transform.position - hitPosition; m_RGB.AddForce(vec * power, ForceMode2D.Impulse); StartCoroutine(m_FlashScript.FlashAlpha()); }
// Apply knockback to player based on hazard values public void ApplyKnockback(float duration, float power, int damage) { m_KnockBackTime = duration; Vector3 vec = -m_LastDirection; m_RGB.AddForce(vec * power, ForceMode2D.Impulse); if (!m_IsBlocking) { m_PlayerScript.RemoveHealth(damage); StartCoroutine(m_FlashScript.FlashAlpha()); } }