im making a fps game and i need a code that will make my bullets damage enemies.
what bullets are you using is it raycast or actual bullets
if its a raycast one add this code
var damage:float = 4;
function Update () {
//your fire bullet code(rate of fire,bullet--;//.etc)
var hit:RaycastHit;
//physics raycast code
if(hit.transform.tag =="Enemy"){
hit.transform.SendMessage("Damage",damage,SendMessageOption.DontRequireReceiver);
}
}
if it is an actual bullet then creaate sendmessage option in same way(using OtriggerEnter or similar ones)
To apply damage add this code to your enemy
var life:float = 100;
function Damage(damage:float){
life-=damage;
}