void GeneratePopulator(TreePopulators populator) { //Vector3 randPoint = GetRandomPositionOnBranch(); //Gets a random point within collider Vector3 genRandPoint = new Vector3(Random.Range(0, branchCollider.bounds.extents.x * 2), Random.Range(0, branchCollider.bounds.extents.y * 2), Random.Range(0, branchCollider.bounds.extents.z * 2)); Debug.Log(genRandPoint); TreePopulators pInst = Instantiate(populator, branchCollider.bounds.min + genRandPoint, Random.rotation); pInst.gameObject.SetActive(true); }
void GeneratePopulator(TreePopulators populator) { //Vector3 randPoint = GetRandomPositionOnBranch(); //Gets a random point within collider float randomZ = Random.Range(0, transform.localScale.z); Vector3 forwardDir = transform.position + transform.TransformDirection(0, 0, randomZ); //Vector3 genRandPoint = new Vector3(Random.Range(0, branchCollider.bounds.extents.x *2), Random.Range(0, branchCollider.bounds.extents.y * 2), Random.Range(0, branchCollider.bounds.extents.z * 2)); //genRandPoint = TransformPointUnscaled(transform, genRandPoint); TreePopulators pInst = Instantiate(populator, forwardDir, Random.rotation); pInst.gameObject.SetActive(true); }