Event when a character using Health is hit?

Hello,

I'd like to ask if there's any specific event that gets triggered when a Health component's any of the hit boxes get hit? I want to apply certain debuff when I hit enemy targets and heal friendly targets, which also leaves the question how should I deal with hitting friendly targets? What layer they should be on? Enemy layer for enemies and Character layer for friendlies? I'd prefer to not really depend on layers but rather have a script that has a string with a "TeamId" so I can swap teams easily at runtime.

All of these will have a Health component attached.
 
Heal and damage are different things in UCC (either the Heal or the Damage methods are called).

You can write your own damage processor to avoid friendly targets being damaged:

There is also an OnObjectImpact event that you can use to do different things when an object is hit (like writing your own heal logic):
 
Heal and damage are different things in UCC (either the Heal or the Damage methods are called).

You can write your own damage processor to avoid friendly targets being damaged:

There is also an OnObjectImpact event that you can use to do different things when an object is hit (like writing your own heal logic):

Is there an event when the character gets damaged but the health is already 0?

EventHandler.RegisterEvent<float, Vector3, Vector3, GameObject, Collider>(gameObject, "OnHealthDamage", OnDamage);


OnDamage doesnt get called if the health is 0, Im making my enemies enter a critical state when the health is 0 (similar to Doom) but I want to be able to still damage them and insta kill them if so.
 
No, there's not. You could subclass CharacterHeath and add your own though.
 
No, there's not. You could subclass CharacterHeath and add your own though.

Do you mean creating a new CharacterHealthCritical script and doing something like this

public class CharacterHealthCritical : CharacterHealth { private Attribute _healthAttribute; protected override void Awake() { base.Awake(); if (TryGetComponent(out AttributeManager attributeManager)) { if (!string.IsNullOrEmpty(m_HealthAttributeName)) { _healthAttribute = attributeManager.GetAttribute(m_HealthAttributeName); } } } public override void Damage(DamageData damageData) { if (_healthAttribute.Value <= 0) { Debug.Log("Damanged in critical"); EventHandler.ExecuteEvent(m_GameObject, "DamagedWhenHealthIsZero"); } base.Damage(damageData); } }
 
Last edited:
Top