- Home /
Remove space between two objects at runtime
hi all I am new to unity 5 and i am creating a football game with kinect i have created a stadium in which i want to create audience at runtime
Finally The code i m generate for creating audience using UnityEngine; using System.Collections;
public class Audience : MonoBehaviour {
public GameObject audiance;
public GameObject audiance1;
public GameObject audiance2;
public GameObject audiance3;
public GameObject audiance4;
public GameObject audiance5;
//public float spacing = -1.8f;
float zSpace = -1.8f;
int x;
void Start() {
for (x = -2; x <= 5; x++)
{
createAudiance();
createAudiance1();
createAudiance2();
createAudiance3();
createAudiance4();
createAudiance5();
}
}
// Update is called once per frame
void Update () {
}
public void createAudiance()
{
//Vector3 pos = new Vector3(x , -4.492f, 8.544f);
//float temp;
//temp = audiance.transform.position.x + zSpace;
Vector3 pos = new Vector3(x, -4.492f,8.544f );
Instantiate(audiance, pos,Quaternion.Euler(0,-180,0));
}
public void createAudiance1()
{
Vector3 pos = new Vector3(x, -4.36f, 9.04f);
Instantiate(audiance1, pos,Quaternion.Euler(0,-180,0));
}
public void createAudiance2()
{
Vector3 pos = new Vector3(x, -4.186f, 9.309f);
Instantiate(audiance2, pos,Quaternion.Euler(0,-180,0));
}
public void createAudiance3()
{
Vector3 pos = new Vector3(x, -4.018f, 9.77f);
Instantiate(audiance3, pos,Quaternion.Euler(0,-180,0));
}
public void createAudiance4()
{
Vector3 pos = new Vector3(x, -3.854f, 10.09f);
Instantiate(audiance4, pos,Quaternion.Euler(0,-180,0));
}
public void createAudiance5()
{
Vector3 pos = new Vector3(x, -3.692f, 10.53f);
Instantiate(audiance5, pos,Quaternion.Euler(0,-180,0));
}
} The above code created my audience but i am unable to remove space between two game object
Plz provide me solution for this Thank You
Comment
Your answer
Follow this Question
Related Questions
Make Objects to ricochet 1 Answer
Move object towards an angle the distance of two points 1 Answer
How to check if an object is colliding with another? 3 Answers
Vector between two objects 1 Answer