Skip to content

Instantly share code, notes, and snippets.

@unity3dcollege
Created December 31, 2016 02:13
Show Gist options
  • Save unity3dcollege/cd53a8bb97693cf6545eb335d36d22e5 to your computer and use it in GitHub Desktop.
Save unity3dcollege/cd53a8bb97693cf6545eb335d36d22e5 to your computer and use it in GitHub Desktop.
using UnityEngine;
public class NPCDamager : MonoBehaviour
{
private void Update()
{
if (Input.GetButtonDown("Fire1"))
{
DamageNPCs();
}
}
private void DamageNPCs()
{
foreach (var npc in FindObjectsOfType<NPC>())
{
npc.TakeDamage(5);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment