- Home /
I cant change tag on two objects simultaneously? Why?
I use collider to stop an object and triggering them using tags. Before I tried to use booleans, result is the same. I cant change two objects simultaneously/
Where is a problem?
void Update () {
trigger = numb%2==0;
if(Input.GetButtonDown("Jump") && trigger){
numb++;
collider1.tag = "Untagged";
collider2.tag = "Obstacle";
}
if(Input.GetButtonDown("Jump") && !trigger){
numb++;
collider1.tag = "Obstacle";
collider2.tag = "Untagged";
}
}
what error is it giving you? is collider a gameobject or the collider on the gameobject?
Are you sure you aren't changing the tag on the same object twice?
maccabbe, you see code, I think there is no double changes of tag
With the word "Simultaneous" I mean one update call.The result I am seeing in Inspector at runtime
Answer by KazakhOnMoon · Jun 28, 2015 at 12:03 PM
I found answer. Initially I created empty gameobject and put two colliders into it. I have two such gameobjects.Problem is that when I want to change two gameobjects tag at one update call, First one changes, but second is not.
The answer is to change not the gameobject's tag but the tag of colliders in the gameobject.
I dont know why, but it works.
Anyone have ideas?
Your answer
![](https://koobas.hobune.stream/wayback/20220613201431im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Undefind tag? 0 Answers
Using tags in edit and build 0 Answers
Turn off multiple lights 0 Answers
Making object switch between two tags every 3 seconds 3 Answers
Counting players by trigger Problem 0 Answers