- Home /
Question by
gremlin022 · Oct 25, 2011 at 07:56 PM ·
gameobjectdamagehealth
Health DMG 5x gameobject
Hi
I've got two scripts 1st HP22
static var Health : int = 1000;
private var Health2 : int = Health;
function Update(){
if (Health != Health2) {
print("Obrazenia: ");
print(Health2-Health);
Health2 = Health;
}
if (Health<=0)
{
Destroy(gameObject);
}
}
function ApplyDamage (DMG : int)
Health-=DMG;
}
^This is component in 5 Object^ and 2nd ToTheAim
static var Predkosc : int = 10;
private var rodzaj = "Rakieta";
var wCo : GameObject;
function Update () {
if (Skile.SkillNr4.transform.position == null) Destroy(gameObject);
gameObject.transform.LookAt(Skile.SkillNr4.transform.position);
transform.Translate(Vector3.forward * Time.deltaTime *Predkosc);
}
function OnCollisionEnter (other : Collision){
wCo = other.gameObject;
other.gameObject.GetComponent("HP22").BroadcastMessage("ApplyDamage", 200);//.Obrazenia(200, rodzaj, gameObject, wCo);
print(wCo);
Destroy (gameObject);
}
^This is component in my Rocket^
When my rocket hitting Cube with HP22 component dealing damage all 5 cube's. When my rocket hit only one cube 5x then destroying all 5 cubs. :[ i was using SendMessage and change nothing, allways destroy 5 cubs. My ask: WHY? and how to deal damage to one script?
PS: Yes, i know. My englis is not so good :]
Comment
Your answer
Follow this Question
Related Questions
Looking for skilled individual to assist with problem 1 Answer
Damage to Health 2 Answers
Decrase value on collision C# 2 Answers
damage health script ineffective, no noticable mistakes 2 Answers
How to cause damage on collision? 1 Answer