- Home /
Convert To Using Array
I have the following code I have work for on light in my scene to rotate, but instead I want to make it so that you can use an array of lights and have them rotate.
Here is the code I have that works awesome but only for one light:
public Transform rotation;
transform.RotateAround (rotation.position, Vector3.forward, ((Time.deltaTime / CircleCycleLength) * 360.0f));
Answer by Slev · Sep 18, 2014 at 04:03 PM
foreach (Light l in LightArray)
//Do transform on l
LightArray is just the name of the array holding your lights.
Answer by Illusory_Stone · Sep 18, 2014 at 04:09 PM
If you have multiple lights, attach the script to each one. Make sure to set rotation.position to the transform.position of the item you wish to circle about, assuming I read your intention correctly? Otherwise, set the transform.position to a global location.
I would do that but there is a lot more to the script then just that part. I was just breaking out where my problem is.
Your answer
![](https://koobas.hobune.stream/wayback/20220613163252im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Using an array instead 2 Answers
How to select adjacent cubes along edges? 2 Answers
Array Issue 1 Answer