- Home /
Question by
Stephanides · Nov 28, 2014 at 06:13 PM ·
instantiatedynamicwall
Problem with dynamic wall
Hello, i have a problem, im trying to make dynamic wall, i instantiate one prefab and when its distance bigger than lenght of prefab i instantiate next prefab, it works good but how i can now make straight wall ? because i never set mouse position on the same axis.. Thanks for advice
plot.png
(336.7 kB)
Comment
I have an idea, spawn first prefab outside of loop and find out his rotation and than when i spawn second prefab i set his rotation same like first prefab, but i dont know how to do this :D
This would be easier to sort out if you posted your spawning code.
void VytvorStenu(){
float distance = Vector3.Distance (start.transform.position, end.transform.position);
Vector3 poziciaaa = end.transform.position - start.transform.position;
poziciaaa.Normalize ();
float x;
Vector3 pozicia = start.transform.position;
poziciaaa = 119 * poziciaaa;
if (distance > 119) {
plocik = (GameObject)Instantiate (plot, pozicia, Quaternion.identity);
plocik.transform.LookAt (end.transform.position);
plocik.transform.parent = $$anonymous$$ontainer;
pozicia = pozicia + poziciaaa;
start.transform.position = pozicia;
}
for (x = 238; x < distance; x+=119) {
plocik = (GameObject)Instantiate (plot, pozicia, Quaternion.identity);
plocik.transform.LookAt (end.transform.position);
plocik.transform.parent = $$anonymous$$ontainer;
pozicia = pozicia + poziciaaa;
start.transform.position = pozicia;
}
float rozdiel = distance - x + 119;
if (rozdiel > 30) {
rozok = (GameObject)Instantiate (roh, pozicia, Quaternion.identity);
rozok.transform.LookAt (end.transform.position);
rozok.transform.parent = $$anonymous$$ontainer;
}
//Destroy(stena);
}