- Home /
Creating new variables through incrementing
So, I have a wall of 2d bricks, and when you click on any of the bricks, it is destroyed and a 3d brick is instantiated on that spot and flies forward. If you click on the flying 3d brick, it then gets destroyed and a new 2d brick needs to emerge in the spot of the original.
tempRedBrick = Instantiate(prefabBrick, transform.position, transform.rotation);
static var posBrick: Vector3 = transform.position;
static var rotBrick: Quaternion = transform.rotation;
Using this code, I get the original position of the 2d brick on the wall, and the new 2d brick is instantiated there. However, it always uses the position of the last 2d brick clicked. I have a static var that increments every time you click on a 2d brick on the wall, I was wondering if there was a way to use this variable in combination with the position and rotation storing variables. This way, the game understands where the 3d brick originally emerged from.
e.g. can I start with something like posBrick0 then the next 2d brick that is clicked is posBrick1, then posBrick2, etc. ?
Is there some way I can connect that var number and create a