void PrepareNextObject2() { uint nextObjectHeight = (uint)Random.Range(1, (int)screwdriverController.totalHeights + 1); if (nextObjectHeight == objectBehaviour.height) { if (nextObjectHeight > 1) { --nextObjectHeight; } else { ++nextObjectHeight; } } objectBehaviour.height = nextObjectHeight; Debug.Log("Next object height: " + nextObjectHeight); switch (objectBehaviour.height) { case 1: objectBehaviour.GetComponent <MeshFilter>().mesh = objectBehaviour.mesh1; objectBehaviour.GetComponent <MeshRenderer>().material = objectBehaviour.material1; break; case 2: objectBehaviour.GetComponent <MeshFilter>().mesh = objectBehaviour.mesh2; objectBehaviour.GetComponent <MeshRenderer>().material = objectBehaviour.material2; break; case 3: objectBehaviour.GetComponent <MeshFilter>().mesh = objectBehaviour.mesh3; objectBehaviour.GetComponent <MeshRenderer>().material = objectBehaviour.material3; break; } objectBehaviour.transform.gameObject.AddComponent <BoxCollider>(); objectBehaviour.transform.gameObject.AddComponent <Rigidbody>(); objectBehaviour.transform.rotation = Quaternion.AngleAxis(180.0f, Vector3.up); objectBehaviour.RecalculateSize(); objectBehaviour.RemoveHoles(); objectBehaviour.SpawnHoles(); objectBehaviour.transform.gameObject.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezePositionX | RigidbodyConstraints.FreezePositionZ | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationZ; objectBehaviour.transform.position = new Vector3(0.0f, objectInitialHeight, 0.0f); // TODO: finish positioning... gameState = GameState.moveObjectDown; }