private int selectSimulation = -1;
public int SelectedSimulation() { return selectSimulation; }
// Update is called once per frame
void Update () {
if ( Input.GetMouseButtonDown( 0 ) )
{
int shape = GetComponent<GUIScript>().SelectedShape();
int simulation = GetComponent<GUIScript>().SelectedSimulation();
switch ( shape )
{
// Cube
case 0:
if(!GetComponent<GUIScript>().returnChooseShape() )
{
CubeCount ++;
GameObject cube = GameObject.CreatePrimitive( PrimitiveType.Cube );
cube.name = "Cube" + CubeCount;
cube.tag = "Cube";
Rigidbody cubeRigid = cube.AddComponent<Rigidbody>();
cubeRigid.useGravity = false;
cubeRigid.mass = 10;
cube.transform.localPosition = objPos ;
GetComponent<GUIScript>().resetShape();
//tempCubeCount = CubeCount;
print( camera.transform.localPosition );
}
break;
...
}
if( simulation != -1 )
{
switch ( simulation )
{
// play
case 0:
for(int i =0; i <= CubeCount; i++)
{
i = tempCubeCount;
GameObject.Find ("Cube"+i).gameObject.rigidbody.useGravity = true;
}
//var Cubes = GameObject.FindWithTag("Cube");
//GameObject.FindWithTag("Cube").gameObject.rigidbody.useGravity = true;
// GameObject.FindWithTag
// for(
// gameObject.rigidbody.useGravity = true;
break;
// pause
case 1:
break;
// reset
case 2:
break;
}
}
}
Above are parts of my codes … I would like to know how to find objects of a specific tag and how to make the objects fall … Can anyone kindly explain to me ? ![]()