I have tried to set a toggle to change the sprite and ridigbody for other objects … but the script toggle changes one sees and keeps the sprite, i would also have to add object by object (sprite and rogidbody), is there any way to do so for several by one tag or other criteria… could please help me with some idea or some script! Thank you! SORRY FOR MY ENGLISH!
not entirely sure what you’re doing… but in general terms, if you need to do something to multiple things you’re looking at iterating (i.e. looping through) over some sort of collection (array/list/whatever) and performing the required action on each in turn.
For most of the “get” functions in unity (find###, getcomponent, etc.) there is one variation which retrieves “all of the things that have”.
Unity - Scripting API: GameObject.FindWithTag (get one with the tag)
Unity - Scripting API: GameObject.FindGameObjectsWithTag (get all with the tag)
Unity - Scripting API: GameObject.GetComponent (get one component of type)
Unity - Scripting API: GameObject.GetComponents (get all components of type)
these “get all” functions return an array you can then iterate over.