How to rotate all clones using single slider


Basically what I’m trying to do is to create a slider that would rotate all instantiated clones around their y axis. So far all my clones have their own slider, which rotates them, but this rotation is applied to only 1 clone. Is there any solution to this issue?

Here’s my script:

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class FireSpreader : MonoBehaviour {

public ParticleSystem Fire;
public GameObject fireSpreader;
[Range(0.0f, 360.0f)]
public float rotation;

void Start () {


void Update () {

	List<GameObject> fireSpreaders = new List<GameObject> ();

	Vector3 fireSpreaderRotation = new Vector3 (0,rotation,0);

	Ray ray = new Ray (transform.position, transform.forward);
	RaycastHit hit;
	if (Physics.Raycast (ray, out hit)) {
		if (hit.collider.transform.childCount == 0 && hit.collider.tag == "Tree") {
			hit.collider.tag = "Burning Tree";

			Vector3 fireRotation = new Vector3 (270, 0, 0);

			GameObject newFireSpreader = (GameObject)Instantiate (fireSpreader, hit.collider.transform.position, Quaternion.identity);
			ParticleSystem newFire = (ParticleSystem)Instantiate (Fire, new Vector3 (hit.collider.transform.position.x, hit.collider.transform.position.y - 20, hit.collider.transform.position.z), Quaternion.Euler (fireRotation));

			newFireSpreader.transform.parent = hit.transform;
			newFire.transform.parent = hit.transform;
			newFire.transform.localScale = new Vector3 (0.9940113f, 1, 1);
	foreach (GameObject spreader in GameObject.FindGameObjectsWithTag("Fire Spreader")) {
		fireSpreaders.Add (spreader);
		transform.rotation = Quaternion.Euler (fireSpreaderRotation);


There are a few ways to do this but I would suggest creating some kind of rotation controller class that has a list of objects whose rotation it controls and the rotation itself. Add each of your clones to a list and have the Controller class rotate the objects. Something like below. I am just writing this off the top of my head so you may not be able to copy/paste exactly :slight_smile:

public float rotation;
public List<Transform>() objectsToRotate = new List<Transform>();

private void RotateObjects()
    foreach(Transform t in objectToRotate)
        t.rotation = rotation;