- Home /
Best Answer
Answer by deltamish · Nov 01, 2012 at 02:00 PM
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;
}
Your answer
Follow this Question
Related Questions
How do i make a fps where the gun always shoots realisticly 3 Answers
Health and Damage [C#] 2 Answers
Bullet Collision Issues 1 Answer
Transform.position bullet won't align 1 Answer
Question about Gun Sounds 1 Answer