- Home /
Question by
ElementalVenom · Oct 08, 2015 at 12:41 AM ·
collidertriggertagtags
Undefind tag?
So ive been using unity for about 2 weeks now with no problems what-so-ever in any of these 2 scripts. But after editting a bit of code today that had to do with damage rates(It shouldnt have effected the tag system at all) I am getting a "GameObject has undefined tag!" Error in 2 of my scripts that check tags. All of my gameobjects have tags.So i have no idea what the problem could be?
SCRIPT 1:
void shoot(int Damage,int Range){
/*
Direction=transform.FindChild("Armature").forward;
float Offset=.1f;
Direction.x+=Random.Range(-Offset,Offset);
Direction.y+=Random.Range(-Offset,Offset);
*/
if(Physics.Raycast(transform.position,transform.FindChild("Armature").forward, out hit,Range) && canShoot){
if(hit.transform.tag==("Zombie") && hit.transform.GetComponent<Health>()!=null && hit.transform.GetComponent<Health>().dieID==2){
hit.transform.GetComponent<PhotonView>().RPC("takeDamage",PhotonTargets.AllBuffered,Damage);
}
Debug.Log("HIT: "+hit.transform.tag.ToString());
drawRays=true;
}else{
drawRays=false;
}
}
I get a error on the if statement involving the Zombie tag.
And in SCRIPT 2:
void OnTriggerEnter (Collider col){
if(col.transform.tag=="Player" && !triggerLocked && PhotonNetwork.isMasterClient){
target=col.gameObject;
triggerLocked=true;
}else if( col.transform.tag == "Untagged" ){}
}
I get a error checking the Player tag.
Comment