|
I am working on a script to turn on and off multiple guitexts. It is here:
This works to turn off one of the items with the tag house, but only one. How do I change it to work for all of them?
(comments are locked)
|
|
You can use GameObject.FindGameObjectsWithTag to get a list of all of the objects with that tag; then just iterate through the list and do it to each one. Edit: here's an example. I could do it like that, but I was trying to avoid having to go through and write a line of script that does it to each one (as I have about 20 for each different tag), is there any other way?
Feb 21 '11 at 09:46 PM
Timmyglen2
@Timmyglen2: going through each one is the only possible way; that's how computers work. As Molix said, just iterate through the array, it's trivial.
Feb 21 '11 at 10:09 PM
Eric5h5
How would I go about this? I looked at the page, but I didn't understand any of it.
Feb 21 '11 at 10:27 PM
Timmyglen2
is there a quicker way mine seems to take a second to do it to all of them at the momment im disabling all parts of a character from kinematic to enter a rigidbody state from animation. and it just seems to jump and then do it like its taking it a second to process it all. in an old script i had i had all the different pieces written down in a long script and then i simplified it with a loop but it seems slower, is this because its got to find all the different parts before doing it. my script is only enabled when a user presses a button. should i enable the script and make an array of the objects and then put them into a if statement.
Feb 22 '12 at 02:08 AM
reptilebeats
scratch that last one, ill leave it there anyway as it may help people.. basically its late and im real slow and didnt realise that my animation was the problem not the loop, because my animation is constantly looping when my character goes into ragdoll its still trying to play the animation and takes a second to ignore it. simple destroy worked fine
Feb 22 '12 at 02:38 AM
reptilebeats
(comments are locked)
|
