public void OnRaycast() { RaycastHit hit; if (Physics.Raycast(transform.position, transform.TransformDirection(Vector3.down), out hit, 0.5f)) { if (hit.transform.tag == "Cube") { isFall = false; transform.position = Absolutaize(transform.position); body.constraints = RigidbodyConstraints.FreezeAll; if (transform.position.y > Tower.highestColumn) { tower.AddLayerCubes((int)color, gameObject); } else { tower.LandedCube(gameObject); } } if (hit.transform.tag == "Ground") { isFall = false; transform.position = Absolutaize(transform.position); body.constraints = RigidbodyConstraints.FreezeAll; if (transform.position.y > Tower.highestColumn) { tower.AddLayerCubes((int)color, gameObject); } else { tower.LandedCube(gameObject); } } } }