I need to somehow change all my gameobjects with the tag “StopUse” to “Platform” whenever i press R because when my bullet hits a platform it is suppose to change the tag to “StopUse” as this was an fix with a bug i had. So when i press R to reset my map i need the platforms with the tag “StopUse” back to “Platform”
Something that temporarily changes the tag could also help.
You declare a list of game objects, and have the list receive the result of the FindGameObjectsWithTag() method. After this you can simply do a foreach loop in which you change the tags manually. Something like this (not tested):
Searching game objects like this is not really optimal, but I guess it is the easiest way to change all of them without having to assign a different script to each object. If you care more about performance than the trouble in doing it, attach a script in all your objects that have the tag “StopUse”, in a way that the script checks if the current tag is “StopUse” and if there is a press on the button, if so you simply change the tag manually to “Platform”… Like this:
void Update()
{
if (Input.GetKeyDown(KeyCode.R))
{
if (this.gameObject.tag == "StopUse)
{
this.gameObject.tag = "Platform";
}
}
}