- Home /
 
               Question by 
               zero3growlithe · Dec 11, 2011 at 11:43 AM · 
                changetargetnamein-game  
              
 
              How to use Float as Name in GameObject.Find command?
How to make GameObject.Find(Variable i.e 1,2,3,4,5...) work? My object's names are same as above, that is from 1 to 27 and i want to switch between them without using switch function. For example: if i'll get to object named "1" then change my target to object named "2".
               Comment
              
 
               
               
               Best Answer 
              
 
              Answer by Statement · Dec 11, 2011 at 02:59 PM
Every object have a function called ToString(). This often give you a user friendly string representation of the object. In the case of the float type, it'll give you the value in text format. Beware of decimals as decimal separators are different in different cultures though.
 float value = 2;
 GameObject.Find(value.ToString());
Your answer
 
 
              koobas.hobune.stream
koobas.hobune.stream 
                       
                
                       
			     
			 
                