- Home /
Collision, tags, and triggers
#pragma strict
var Damage = 1000;
function OnTriggerEnter (col : Collision) {
var Script : HealthMUTO = GameObject.Find("Muto").GetComponent(HealthMUTO);
if (col.tag == "MUTO")
{
Script.Health -= Damage;
}
}
I'm making a Godzilla game, and that is for the fire or the punch on the MUTO. But I'm getting an error that says that "tag" isn't a member of "UnityEngine.Collision". I don't quite understand, since I've worked with this before, but the assets of that project got corrupted.
Answer by tanoshimi · Oct 21, 2014 at 09:09 PM
col should be a Collider, not a Collision.
I'm having another issue here, no errors, but it wont work. The other script's this:
#pragma strict
var Health = 10000;
function Update () {
if (Health <= 0)
{
Destroy(gameObject);
}
}
The claw passes through $$anonymous$$UTO's collider and his health doesn't go down. I've had many experiences like this before. Oh and the $$anonymous$$UTO stays put, the trigger is the one to move. Is that the issue? Do I need a rigidbody on one of them?
Edit: Never$$anonymous$$d, I'm stupid, I solved it (and very easily so).