So I want to fairy to spawn in a formation of Left 4 and Right 4 but it seems there is always one got offset in Y axis position. As indicated by the arrow I add where they should be.
public class GreenFairyFormation2 : MonoBehaviour {
public GameObject GreenFairy1;
public GameObject GreenFairy2;
public GameObject GreenFairy3;
public GameObject GreenFairy4;
public GameObject GreenFairy5;
public GameObject GreenFairy6;
public GameObject GreenFairy7;
public GameObject GreenFairy8;
Vector2 LeftFormationStartPos = new Vector2(-7f, 4.8f);
Vector2 LeftFormationStartPos1 = new Vector2(-6.5f,4.8f);
Vector2 LeftFormationStartPos2 = new Vector2(-6f, 4.8f);
Vector2 LeftFormationStartPos3 = new Vector2(-5.5f, 4.8f);
Vector2 RightFormationStartPos = new Vector2(7f, 4.8f);
Vector2 RightFormationStartPos1 = new Vector2(6.5f, 4.8f);
Vector2 RightFormationStartPos2 = new Vector2(6f, 4.8f);
Vector2 RightFormationStartPos3 = new Vector2(5.5f, 4.8f);
// Use this for initialization
void Start ()
{
InvokeRepeating("LeftFormation", 8f, 0.8f);
InvokeRepeating("RightFormation", 8.5f, 0.8f);
}
// Update is called once per frame
void Update ()
{
if(StageTimerControl.TimerClick > 15f)
{
CancelInvoke("LeftFormation");
CancelInvoke("RightFormation");
}
}
void LeftFormation()
{
Instantiate(GreenFairy1);
GreenFairy1.transform.position = LeftFormationStartPos;
Instantiate(GreenFairy2);
GreenFairy2.transform.position = LeftFormationStartPos1;
Instantiate(GreenFairy3);
GreenFairy3.transform.position = LeftFormationStartPos2;
Instantiate(GreenFairy4);
GreenFairy4.transform.position = LeftFormationStartPos3;
}
void RightFormation()
{
Instantiate(GreenFairy5);
GreenFairy5.transform.position = RightFormationStartPos;
Instantiate(GreenFairy6);
GreenFairy6.transform.position = RightFormationStartPos1;
Instantiate(GreenFairy7);
GreenFairy7.transform.position = RightFormationStartPos2;
Instantiate(GreenFairy8);
GreenFairy8.transform.position = RightFormationStartPos3;
}
}
So I have Instatiate Object and right after it to set it’s position,I don’t think this the best way but should they should be in one line, having same y right?
