player ์ค์ฌ์ผ๋ก ๋๊ฒ ํ๋ ค๊ณ ํ๊ณ ์ถ์๋ฐ, ๊ณต์ ์ฒด๊ฐ 1๊ฐ ์ด๋ฉด ์๊ด ์๋๋ฐ ๊ณต์ ์ฒด๊ฐ ๋๊ณ ์๋ ์ํฉ์์ 1๊ฐ ๋ ์ถ๊ฐ๋๋ฉด ๊ณต์ ์ฒด ์ฌ์ด์ ๊ฐ๊ฒฉ์ด ๋๊ฐ์ด ์ ์ง๋๊ฒ ๋ฐ๊พธ๋ ค๋ฉด ์ด๋ป๊ฒ ํด์ผํ ๊น? ์ด ๊ณต์ ์ฒด 4๊ฐ๋ก ๋ง๋ค๊ณ ์ถ์ด!ย
์๋ ์ฝ๋๋ ๋ด๊ฐ ์ด ๊ณต์ ์ฝ๋ ์ธ๋ฐ, ๋ค๋ฅธ ์คํฌ๋ฆฝํธ์์ ๊ณต์ ์ฒด 1๊ฐ์ฉ ๋์ด๋ ๋๋ง๋ค ๋งจ ๋ฐ ํจ์ ํธ์ถํด์ ์์น ์กฐ์ ํ๋ ค๊ณ ํด! ๋ญ๊ฐ ์๋ชป ๋ ๊ฑธ ๊น?
public class EarthWeapon : MonoBehaviour { public float damage = 5f; public GameObject Player; public float speed; Vector3 offset; bool check = true; private void Start() { offset = transform.position - Player.transform.position; } private void Update() { if (check) { OrbitAround(); } } void OrbitAround() { transform.position = Player.transform.position + offset; transform.RotateAround(Player.transform.position, new Vector3(0,0,1), speed * Time.deltaTime); offset = transform.position - Player.transform.position; } public void setposition(int a) { check = false; if (a == 1) { transform.position = offset + new Vector3(1, 1, 0) + Player.transform.position; check = true; } if (a == 2) { transform.position = offset + new Vector3(-1, -1, 0) + Player.transform.position; check = true; } if (a == 3) { transform.position = offset + new Vector3(1, -1, 0) + Player.transform.position; check = true; } if (a == 4) { transform.position = offset + new Vector3(-1, 1, 0) + Player.transform.position; check = true; } } }
Orbiting to maintain distance between orbitals Unity
๋ถ๋ชจ ์ค๋ธ์ ํธ๋ฅผ ๋ง๋ค๊ณ ๋ฐ์ ๊ณต์ ํ ์ค๋ธ์ ํธ๋ค์ ๋์ -> ๊ณต์ ์ฒด๋ฅผ (360 / ๊ณต์ ์ฒด๊ฐฏ์ * ์์ ์ index)๊ฐ๋๋ก ์ผ์ ๊ฑฐ๋ฆฌ๋งํผ ์ด๋ํ๊ฒ ์ด๊ธฐํํจ -> ๋ถ๋ชจ ์ค๋ธ์ ํธ๋ฅผ ๋๋ฆผ / ํ๋์ฝ๋ฉ๋ณด๋ค ์ด ๋ฐฉ์์ ์ด๋
์ด์ผ ์ง์ง ์ด๊ฑฐ ๋ง๋๋ฏ
์ ๋ด ๋๋ก๋ ๊ตฌํ ๋ถ๊ฐ๋ฅํจ.. ์ฝ๋ ์กฐ๊ธ๋ง ์์ฑ ํด์ฃผ์ค์ ์์ผ์ฌ?
์ค์ค ์๊น๋ค์ด๊ฐ ์ฝ๋ ๊ตฟ๊ตฟ
ํํ ํผ๋๋ฐฑ ๋ฃ๊ณ ๊ณ ์ณค์ด ใ
ใ ใ
https://gall.dcinside.com/mgallery/board/view/?id=game_dev&no=108172