Hi guys, I have a problem which I can't seem to work out. I have a list and when I add an item to the list it will create a sphere. Simple enough, but how would I then assign a different position for each of those spheres that have been created? I attempted to add item and pass 3 float values and then change them to a vector 3 after the sphere was created but it didn't work, all it does is set the position back to default. Any advice would be welcome.
List<Sphere> spheres; void Start () { spheres= new List<Sphere>(); SpawnSpheres(); } void SpawnSpheres() { spheres.Add(new Doorway(25, 45, 1)); spheres.Add (new Doorway(0,0,0)); spheres.Add(new Doorway(2, 4, 1)); foreach(Sphere Madespheres in spheres){ GameObject sphere = GameObject.CreatePrimitive(PrimitiveType.Sphere) sphere.transform.localScale = new Vector3(300, 300, 300); } } } public class Spheres { public Spheres (float x, float y, float z) {
So as you can see, I am passing the float values but I need to apply them to the individual list items.
Never mind, I realised I didn't need the Foreach loop and just needed to pass the parameters, I was staring at it too long I suppose.