miroslaw88
New member
Hello, I was wondering what the best way to implement friendly-fire damage would be? At the moment I am subclassing "CharacterHealth" and overriding the "OnDamage" method:
The issue is there isn't much to work with in terms of receiving "custom" data such as "what team is the player on that shot me". I originally was doing a attacker.GetComponent<MyPlayer>().team ("team" is just an int denoting what team a player is on) check, but the performance hit by doing that on each "OnDamage" call is not great.
Is there an easy way to extend what kind of information gets passed when attacking objects/players?
C#:
public override void OnDamage(float amount, Vector3 position, Vector3 direction, float forceMagnitude, int frames, float radius, GameObject attacker, object attackerObject, Collider hitCollider)
{
//determine what team the "attacker" that shot me is on
base.OnDamage(amount, position, direction, forceMagnitude, frames, radius, attacker, attackerObject, hitCollider);
}
The issue is there isn't much to work with in terms of receiving "custom" data such as "what team is the player on that shot me". I originally was doing a attacker.GetComponent<MyPlayer>().team ("team" is just an int denoting what team a player is on) check, but the performance hit by doing that on each "OnDamage" call is not great.
Is there an easy way to extend what kind of information gets passed when attacking objects/players?
Last edited: