public void PlaceObjByGraph(GameObject obj1, GameObject obj2) { place = ScriptableObject.CreateInstance <PlaceObjectToGround>(); //Debug.Log("graph length: "+graphLength); for (int i = 0; i < vec3points.Length; i++) { if (i % rar == 0) { GameObject tempObj = Instantiate(obj1, start); tempObj.transform.position = vec3points[i]; place.Place(ref tempObj); } //Debug.Log(transform.name+" | i: "+i+" | " +vec3points[i]); if (i % 10 == 0 & i != 0) { GameObject tempObj2 = Instantiate(obj2, start); tempObj2.transform.position = vec3points[i]; place.Place(ref tempObj2); tempObj2.transform.position = new Vector3(tempObj2.transform.position.x, tempObj2.transform.position.y + 4.5f, tempObj2.transform.position.z); } } }
public void PlaceObjByGraph(GameObject obj) { //Debug.Log(obj.name); place = ScriptableObject.CreateInstance <PlaceObjectToGround>(); rotCalc = ScriptableObject.CreateInstance <RotationCalculator>(); rotCalc.rectRad = 1.0f; rotCalc.rectRadZ = 1.0f; rotCalc.yMod = 2.0f; rotCalc.maxAngleX = 60.0f; rotCalc.maxAngleZ = 45.0f; //Debug.Log("graph length: "+graphLength); GameObject tempObj; float rnd = 0.2f; for (int i = 0; i < vec3points.Length - 1; i++) { if (i % rar == 0) { tempObj = Instantiate(obj, objsParent); tempObj.transform.position = new Vector3(vec3points[i].x, vec3points[i].y + offset, vec3points[i].z); tempObj.transform.parent = objsParent; rnd = 0.2f; tempObj.transform.rotation = new Quaternion( tempObj.transform.rotation.x, tempObj.transform.rotation.y + Random.Range(-rnd, rnd), tempObj.transform.rotation.z, tempObj.transform.rotation.w ); tempObj.transform.rotation = Vec3Mathf.GetDir(vec3points[i], vec3points[0]); rotCalc.MakeCalculations(tempObj.transform, tempObj.transform); place.corr = corr; place.Place(ref tempObj); } } tempObj = Instantiate(obj, objsParent); tempObj.transform.position = new Vector3(vec3points[vec3points.Length - 1].x, vec3points[vec3points.Length - 1].y + offset, vec3points[vec3points.Length - 1].z); tempObj.transform.parent = objsParent; tempObj.transform.rotation = new Quaternion( tempObj.transform.rotation.x, tempObj.transform.rotation.y + Random.Range(-rnd, rnd), tempObj.transform.rotation.z, tempObj.transform.rotation.w ); //tempObj.transform.rotation = Vec3Mathf.GetDir(vec3points[vec3points.Length - 3], vec3points[vec3points.Length-2]); rotCalc.MakeCalculations(tempObj.transform, tempObj.transform); place.corr = corr; place.Place(ref tempObj); }
void Awake() { agent = GetComponent <NavMeshAgent> (); handler = GameObject.FindGameObjectWithTag("StepsPool").transform; steps = new Transform[poolSize]; for (int i = 0; i < steps.Length; i++) { steps [i] = Instantiate(stepPrefab, Vector3.zero, Quaternion.identity, handler).transform; steps [i].gameObject.SetActive(false); } rotCalc = ScriptableObject.CreateInstance <RotationCalculator>(); place = ScriptableObject.CreateInstance <PlaceObjectToGround>(); SetParams(); //StartCoroutine(DebugSteps()); }
void Start() { place = new PlaceObjectToGround(); drawCircle1 = new DrawCircle(GetComponent <LineRenderer>()); yVec3 = new Vector3( 0.0f, Vector3.up.y * sqrt2, 0.0f); //normVec3 = vec3 + yVec3; //vec_1a = CalcVec3(1,1); //vec_2a = CalcVec3(2,1); graphLength = (int)(Vector3.Distance(transform.position, target.position) / rad) - limit; Debug.Log("dist to target" + graphLength); vec3points = new Vector3[graphLength]; angle = GetAngle(); CalcGraph(); PlaceObjByGraph(); }