Take and deal damage from 3rd party source

I have this script to damage my AI

//HONORAI AI Damage
if (hitInfo.collider.gameObject.GetComponent<Character>() != null)
{

hitInfo.collider.gameObject.GetComponent<Character>().ReceiveDamage(40, shooter, DamageType.Physical, false);
}
//.............................

I just dont know where to put it. I would like to put it on a bullet.
Pleaese assist Justin.

I looked at the link and found the impact callback, but where would i pout that script?

EDIT:
I copied the direct damage code from your link and added it to a GameObject with a collider. Just for testing. Nothing happeneds. I keep hitting player with this collider but no damage is taken
 
Last edited:
I managed to reciece damage but I am still stuck at giving damage.
Please advice. I have the above damage method to give but don’t know where to put it.
I am using bullets. Should it be on the projectile script ?? And where if so?
I am looking forward to hear from you..
Cheers
 
Thank you for quick reply Justin.
Just to avoid any further confusion from my side.

You are saying that the whole script under the Impact Callback should be placed on the GameObject I want to take damage?

In that script do I put my damage method in the “private void OnImpact” method? Is this correct understood?

I need to call the the GameObject / AI ReceiveDamage method which I think should go under the private void OnImpact.

Thank you for your patience:)

Br Hamid
 
Top