Control game objects by tag


I’m doing a shot’em up game and I need to make the scenery move in the same direction and at the same speed (so I can create the illusion of the camera moving), right now I have an script for this but I think it would be more efficient if I could control all the scenery pieces all at once with my game manager script by using tags, how can I do this?

In the script I would simply use gameobject.translate(Time.deltaTime*SpeedFloat,y,z); as the only thing I need to control is the speed at the scenery moves.

Thanks in advance

If you have a collection of GameObjects in your scene which you require to move all in the same direction at the same rate, I think you would better off grouping them under a parent GameObject and just move the parent. The children of the parent will move automatically due to the transform hierarchy.

As for getting objects with a specific tag in your scene you can use GameObject.FindGameObjectsWithTag().