- Home /
Colliders reading tags as Untagged
Unity 3.4 was crashing just every few minutes on Win 7, so I jumped at the chance to upgrade to 3.4.1.
It doesn't crash quite as often now, and everything I did in 3.4 still works. (...it now crashes several times a day instead of several times an hour.)
The problem I'm having now, is that any new collider that was added with 3.4.1 reads all tags as "Untagged", while the old 3.4 colliders still read the tags properly. (Type of collider doesn't seem to matter)
Any ideas?
Thanks in advance.
how do you mean "reads"? I wasn't aware that colliders returned tags! Are you getting the tag using
collision.gameObject.tag
?
Actually I'm using an "if" statement inside "OnCollisionEnter", like this "if(gameObject.tag == "PlayerAmmo")".
Then I'm using a print statement for debugging. "print(gameObject.tag);".
No matter what object collides, the code inside the if statement doesn't run and the print statement returns UnTagged.
Like I said before, the 3.4 colliders are working just fine, its only the new ones that see them as untagged.
aaahhh- is that exact code what you are using? Because that returns the tag of the object that the script is attached to, not the object that is colliding with it!
No. The way it is written will return the tag of the object that hit it. Here is the full script for one of the objects I'm having the problem with. (all of the scripts use the same basic method.)
It has served me well up until now.
var explosion : Transform; private var clone : Transform;
function OnCollisionEnter (other : Collision) { print(other.gameObject.tag); if(other.gameObject.tag == "PlayerAmmo" || other.gameObject.tag == "Grenade") {
Destroy (gameObject);
clone = Instantiate(explosion,
transform.position, transform.rotation);
}
}
Answer by SCSI_Dog · Oct 04, 2011 at 02:49 AM
var explosion : Transform; private var clone : Transform;
function OnCollisionEnter (other : Collision) { print(other.gameObject.tag); if(other.gameObject.tag == "PlayerAmmo" || other.gameObject.tag == "Grenade") { Destroy (gameObject); clone = Instantiate(explosion, transform.position, transform.rotation); } }
I reinstalled 3.4.1, and fixed most problems. I still have one collider giving me trouble.
It sees the "PlayerAmmo" tag, but still sees "Grenade" as "UnTagged".
I guess I'll go back to 3.4 until they come out with 3.4.2.... Thanks for the help.
Your answer
![](https://koobas.hobune.stream/wayback/20220612234245im_/https://answers.unity.com/themes/thub/images/avi.jpg)