How can I differentiate between melee and shootable weapon?

echtnice

Member
I have not found an event where I can access an attackerObject.

In line 365 I added an EventExecute. Perhaps it is possible to adapt the standard OnHealthDamage event?

Code:
EventHandler.ExecuteEvent<float, Vector3, Vector3, GameObject, object, Collider>(m_GameObject, "OnHealthDamageObject", amount, position, force, attacker, attackerObject, hitCollider);

EventHandler.ExecuteEvent<float, Vector3, Vector3, GameObject, Collider>(m_GameObject, "OnHealthDamage", amount, position, force, attacker, hitCollider);

I tried to keep the event name, but that didn't work with different parameters => (null reference exception).

Using:

Code:
Object ao = attackerObject as Object;
if (ao != null && ao.GetType() == typeof(ShootableWeapon))
... do something different!
 
You could do something like:

Code:
if (attackerObject is ShootableWeapon) {]/code]
 
Thanks, that's shorter.

But how do I get the attackerObject in my code? Will there be an expansion of the OnHealthDamage event in the future?
 
The OnHealthDamage event doesn't provide attackerObject that way, as the source of the health damage can vary. You could check the attacker object's currently equipped weapon. Or instead of using this event, you could use the impact callback events from the melee and shootable weapons separately to handle each case individually.
 
Top