Question by 
               VictorSomar · Jun 11, 2016 at 12:43 PM · 
                c#instantiatevariableclassargument  
              
 
              Changing an argument to a var and vice-versa
Hello,
I am using Instantiate (object, position, rotation);
I have 3 objects defined in a public class like this:
 public class Objects
 {
    public GameObjects Name1, Name2, Name3;
 }
 private Objects objects;
 
 
               I am using this to define their name in another var.
 private string var;
 var = "Name" + Random.Range(1, 4);
 
               Then I am using this var to access the name of the object in the Object public class like this:
 Instantiate (object.var, position, rotation);
 
               And I an getting an error. I am very new to the Unity, C# and programming in general and I have been doing the tutorials for a week, then I stumbled upon this idea to increase the number of diferente enemies, but I don't know how to aply this or if it is even applicable.
What I think is happening is that the Instantiate sees var as a string variable and isn't able to relate it with anything inside the Object class. What I don't know is how I can make he relate to it.
Thanks in advance.
               Comment
              
 
               
              Your answer