So I got this little script that’s supposed to apply some damage to an object.
var health = 100;
var hitPoints = 100;
var maximumHitPoints = 100.0;
private var gotHitTimer = -1.0;
var propWreck : GameObject;
var impactDamage = false;
var damage = 100;
function OnCollisionEnter(collision : Collision) {
if (collision.relativeVelocity.magnitude > 1 && collision.gameObject.tag=="frontalCollider")
impactDamage = true;
if(impactDamage)
hitPoints -= damage;
if (hitPoints <= 10) {
WreckIt();
}
}
function WreckIt () {
Destroy(gameObject);
Instantiate(propWreck, transform.position, transform.rotation);
}
What I am trying to do is control what damages the object using tags and collision.magnitude - just to be sure sometimes I have to hit the object harder to break it down not simply touch it. While at impact with any object - regardless it’s tag works well, I can’t seem to make the tag filtering work. pls help tx