Edit properties of certain list items,Changing properties of objects in a list (c#)
I would like to create an indefinite amount of GameObjects (Spheres). During the game, certain actions will create a new sphere. To keep track of the spheres I would like to make a list since using arrays requires me to know how many spheres there are going to be. Using the following script, I am able to create the spheres and add them to a list. If I try to change the position of a certain GameObject on the list (using Listname[2].transform.position.set(x,y,z) absolutely nothing happens. How can I change the properties of a certrain GameObject in a list? Example:
 using System.Collections;
 using System.Collections.Generic;
 using UnityEngine;
 using UnityEngine.UI;
 
 public class Player : MonoBehaviour {
 
     public GameObject playerSeg;
     public int segNum, p = 1;
     public Vector3 pos = new Vector3(1,1,1);
     private Quaternion test;
     public List<GameObject> SegList;
 
     void Start () {
         SegList = new List<GameObject>();
             CreateSegment();
     }
 
     void Update () {
         SegList [1].transform.position.Set(1,3,1);
     }
 
     void CreateSegment()
     {
         SegList.Add (Instantiate (playerSeg,pos,test));
     }
 
 
     
 }
 
              Your answer
 
             Follow this Question
Related Questions
Using a specific function from a generic object. 0 Answers
Getting objects out of a list and then comparing them 0 Answers
How to delete an object if there is another object of the same type at that position ? 1 Answer
All GameObjects list to a GameObject? 0 Answers
How To Find GameObject From List And Add To Player List 0 Answers