- Home /
Making objects spawn/appear in a triangle formation
i know there is math involved and i want to learn more and want to use math to do it. Oh btw the triangle formation is like the pool game/snooker triangle formation Sorry im new here and i think this is how you tag someone @Bunny83
Comment
Answer by Bunny83 · Nov 21, 2020 at 01:02 AM
Something like this:
public int rows = 4;
public float size = 1f;
void SpawnObjects()
{
float sin60 = Mathf.Sin(Mathf.Pi/3f);
for(int y = 0; y < rows; y++)
{
for(int x = 0; x < y+1; x++)
{
var pos = new Vector2((x-y*0.5f)*size, y*size*sin60);
// Instantiate(obj, pos, Quaternion.identity);
}
}
}
Your answer

Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
How easy is Unity to use to create an android game if you know Java and some C#? 2 Answers
How do i Update a Transforms Position, and how do i have objects face along a spline?? 1 Answer
[C#] AI Behaviour in spherical way like RESOGUN based on Rigidbodies. 1 Answer