- Home /
Question by
justking14 · Oct 19, 2014 at 04:14 AM ·
velocitycirclealgorithm
Creating a circle of alternating sizes
I'm attempting to create a scale formation that goes through an obstacle course using 14 characters and a leader. I've managed to make it work well with 3 characters and the leader, but it needs to create a circle shape with between 4 and 15 units(including the leader).
GameObject[] birds = GameObject.FindGameObjectsWithTag("EditorOnly");
int birdcount = 1;
int birdnumber = 1;
foreach(GameObject bird in birds){
birdnumber++;
}
float radius = birdnumber*.5f;
foreach(GameObject bird in birds){
birdcount++;
Vector3 b = new Vector3(0,0,0);
if(cubeNumber == 4){
b = new Vector3(rigidbody.position.x-(.5f*birdcount)-bird.rigidbody.position.x, 0, rigidbody.position.z-bird.rigidbody.position.z);
}else{
//b = new Vector3((rigidbody.position.x+(.75f*birdnumber))- bird.rigidbody.position.x, 0, rigidbody.position.z- bird.rigidbody.position.z);
if(birdcount == 2){
b = new Vector3((rigidbody.position.x+(.75f*birdcount))- bird.rigidbody.position.x, 0, rigidbody.position.z- bird.rigidbody.position.z);
}else if(birdcount == 3){
b = new Vector3((rigidbody.position.x+(.375f*birdcount))- bird.rigidbody.position.x, 0, (rigidbody.position.z-(.375f*birdcount))- bird.rigidbody.position.z);
}else if(birdcount == 4){
b = new Vector3((rigidbody.position.x+(.375f*birdcount))- bird.rigidbody.position.x, 0, (rigidbody.position.z+(.375f*birdcount))- bird.rigidbody.position.z);
}
if(birdcount == 5){
b = new Vector3((rigidbody.position.x+(.75f*birdcount))- bird.rigidbody.position.x, 0, rigidbody.position.z- bird.rigidbody.position.z);
}else if(birdcount == 6){
b = new Vector3((rigidbody.position.x+(.375f*birdcount))- bird.rigidbody.position.x, 0, (rigidbody.position.z-(.375f*birdcount))- bird.rigidbody.position.z);
}else if(birdcount == 7){
b = new Vector3((rigidbody.position.x+(.375f*birdcount))- bird.rigidbody.position.x, 0, (rigidbody.position.z+(.375f*birdcount))- bird.rigidbody.position.z);
}
}
bird.rigidbody.velocity = b;
}
Comment