FixedUpdate์์ ๋๋ฆฌ๊ณ ์๋๋ฐ
์๊พธ Update ๊ฐ์ ๋ค๋ฅธ ํจ์์์ ์์น ๊ฐ์ ์์ ํ๋ ๊ฒ์ฒ๋ผ
ScreenToWorldPoint ์ขํ ํ๋ฒ, ์ด์ํ ์ขํ ํ๋ฒ ์ด๋ ๊ฒ ๋ฐ๋ณต๋๋ค
position ๊ฐ์ ์ํฅ์ ์ฃผ๋ ์ฝ๋๊ฐ ScreenToWorldPoint ๋ฐ์ ์๋๋ฐ ๋์ฒด ์์ด๋ฌ๋๊ฑฐ์ง
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | using System.Collections; using System.Collections.Generic; using UnityEngine; public class Follow : MonoBehaviour { RectTransform rectTransform; private void Awake() { rectTransform = GetComponent<RectTransform>(); } private void FixedUpdate() { rectTransform.position = Camera.main.WorldToScreenPoint(GameManager.instance.player.transform.position); } } | cs |
๋ด ๋์๋ง WorldToScreenPoint๋ก ๋ณด์ด๋ ๊ฑด๊ฐ