[๐ฌ]
์ง๋ฌธ ๋ต๋ณ์ฉ) ๊ณต์ ์ฒด ๊ตฌํ
์ ๊ณต๊ฐ๋ฐ์(firetruck4545)
2022-09-22 20:29
์ถ์ฒ 2
public class ExplainOrbit : MonoBehaviour
{
int _planetCount
;
public float radius
;
public float speed
;
void Start()
{
_planetCount
= transform
.childCount
;
for(int i
= 0; i
< _planetCount
; i
++)
{
var planet
= transform
.GetChild(i
);
planet
.localPosition
= Quaternion
.AngleAxis(360 / _planetCount
* i
, Vector3
.back
) * Vector2
.right
* radius
;
}
}
void FixedUpdate()
{
transform
.Rotate(Vector3
.forward
* speed
);
}
}
๊ทธ๋ฅ ์๊ฐ๋๋๋๋ก ์ํ์ ์์ฑํ๋๋ฐ
๋ค์๋ณด๋ ๊ตณ์ด _planetCount๋ฅผ ์ธํ์๋ ์์๋?
Start ํจ์ ์์ ๋ถ๋ถ์ ๋ฐ๋ก ๋ค๋ฅธ ๋งค์๋๋ก ๋ฌถ์ด์
๊ฐฏ์ ๋ฐ๋๋๋ง๋ค ํธ์ถํ๋ค๊ฑฐ๋ ๊ทธ๋ ๊ฒ ์์ ํ๋ฉด ๋ ๋ฏ?
๊ฐ์ฌํฉ๋๋ค ํ๋..
ํ๋ ๊ฐ์ฌํฉ๋๋ค