์ ๋ํฐ ๋ฑ์๋ผ์ดํฌ ๋ง๋๋ ๊ฐ์ ์์ ๋ณด๊ณ ์์์ต๋๋ค.
ํ๋ ์ด์ด ์บ๋ฆญํฐ์ ์์ ๊ฐ์ฒด๋ก ๋ฌด๊ธฐ ๋ฐฐ์น ์ค๋ธ์ ํธ๋ฅผ ๋ง๋ค๊ณ ๊ทธ ์ค๋ธ์ ํธ์ ๋ฃ์ ์คํฌ๋ฆฝํธ์์
๋ฌด๊ธฐ๋ฅผ ๋ฐฐ์นํ๋ C# ์คํฌ๋ฆฝํธ๋ฅผ ์ฐ๊ณ ์์๋๋ฐ ์ฌ๊ธฐ์
//๋ฌด๊ธฐ ๋ฐฐ์น ํจ์
void Batch()
{
for (int index = 0; index< count; index++){
Transform bullet =
GameManager.instance.pool.Get(prefabId).transform;
bullet.parent = transform; //๊ฐ์ ธ์จ ์ด์์ ๋ถ๋ชจ๋ฅผ ๋๋ก ๋ฐ๊ฟ
Vector3 rotVec = Vector3.forward * 360 * index / count;
bullet.Rotate(rotVec);
bullet.Translate(bullet.up * 1.5f, Space.World);
bullet.GetComponent<Bullet>().Init(damage, -1); // -1 is Infinity Per
}
}
์์ ์ผ๋ถ ๊ฐ์ ธ์์ ์ด ๋ถ๋ถ
bullet.Rotate(rotVec);
bullet.Translate(bullet.up * 1.5f, Space.World);
bullet.GetComponent<Bullet>().Init(damage, -1); // -1 is Infinity Per
์์ Translate๋ฅผ ํ ๋ Space.World๋ฅผ ๊ธฐ์ค์ผ๋ก ํ๋ ์ด์ ๊ฐ ๋ญ์ง ๊ถ๊ธํฉ๋๋ค.
์ ๊ฐ ์๊ธฐ๋ก ๋ฌด๊ธฐ๋ฅผ ํ์ ์์ผฐ๋ค ํ๋๋ผ๋ Space.World ํ์ ๊ณผ ๊ด๊ณ์์ด ์ด๋๋๋๊น ์์ชฝ ํ๊ณต๊ฐ์ ๋ฌด๊ธฐ๋ค์ด ๊ฒน์ณ์ผ ํ ๊ฑฐ ๊ฐ์๋ฐ
์ํ๋๋๋ก ์ ๋์ค๋ ์๋ฆฌ๊ฐ ๊ถ๊ธํด์ ์ง๋ฌธ๋๋ฆฝ๋๋ค.
์ค ๋๋ ๊ถ๊ธํด์ ์ง์ ํ์ธํด๋ด ํด๋ณด๋ bullet.transform.up์ด bullet์ ํ์ ์ถ์ ๊ธฐ์ค์ผ๋ก ๋๋๋ด ์๊ฐํ๋๋ก ์๋ํ๊ฒ ๋ง๋ค๊ณ ์ถ์ผ๋ฉด bullet.up์ Vector2.up ์ผ๋ก ๋ฐ๊พธ์
bullet.up์ Vector.up์ผ๋ก ๋๋ ์ ์๊ฐ๋๋ก ๋ฌด๊ธฐ๊ฐ ๊ฒน์ณ์ ๋์ค๋ค์ ์๋ฌด๋๋ ์์ง์ด๋ ๋ฒกํฐ๋ฅผ bullet์ ๊ธฐ์ค์ผ๋ก ๋๋ ๋์๋ ๋ด ๋๋ค. ๋ต๋ณ ๊ฐ์ฌํฉ๋๋ค.