- Home /
Question by
uanmanarmy · Aug 07, 2014 at 12:10 PM ·
transformpositionstrings
How to change position after some reference.
Hi, I'm reading from XML file. And I have a string "RBG" - RedBlueGreen.
Im Instantiating a clone of an prefab depending on that string
public void ReadAString(string letter,int j, float i, float yPosition)
{
// Get the specific Letter
switch(letter[j])
{
case 'B':
cube = Item_bbg;
break;
case 'G':
cube = Item_gbg;
break;
case 'O':
cube = Item_obg;
break;
case 'P':
cube = Item_pbg;
break;
case 'R':
cube = Item_rbg;
break;
case 'Y':
cube = Item_ybg;
break;
default: break;
}
//Create a Clone of Item with the specific Prefab and Color
GameObject clone = Instantiate (cube, new Vector3 (i , yPosition, -1), Quaternion.identity) as GameObject;
//Add the Clone in a list for a further use
prefabs.Add(clone);
}
Now On my second level the string will be GBR
or something else like BRG
.
How Can I make to not instantiate new objects, but to switch their position according to the new string.
RBG - This is the string
123 - This is the instantiated objects
GRB - This is the string
312 - new position of instantiated objects
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220613160044im_/https://answers.unity.com/themes/thub/images/avi.jpg)