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