Created
December 31, 2016 02:13
-
-
Save unity3dcollege/cd53a8bb97693cf6545eb335d36d22e5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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