public class Item : MonoBehaviour
{
public EXP exp;
private void Awake()
{
exp = GameObject.FindGameObjectWithTag("EXP").GetComponent<EXP>();
}
private void Start()
{
StartCoroutine("gocircle");
}
private void Update()
{
//StartCoroutine("gocircle");
transform.position = Vector3.MoveTowards(transform.position, exp.transform.position, 0.1f);
}
private IEnumerator gocircle()
{
int theta;
theta = Random.Range(0,100);
Vector3 plusalpha = new Vector3(Mathf.Cos(theta),Mathf.Sin(theta),0f);
transform.position = Vector3.MoveTowards(transform.position, transform.position + plusalpha,0.05f);
yield return new WaitForSeconds(1f);
}
}
먼저 아이템이 원모양으로 퍼지게 한후에 EXP쪽으로 가게 만드려고 하는데 start에서 먼저 실행하고 그뒤에 update가 실행되서 움직여야되는거아닌가요?
바로 Update실행되서 EXP쪽으로 가네요;
스타트 콜루틴 넣었는데 콜루틴 bool 함수 넣고, 코루틴 끝나면 bool=true로 하고 업데이트에는 if(bool==true)하면 됨
start(코루틴 시작) //코루틴 실행중 update(exp쪽으로 가는거) //코루틴 끝 이런식으로 되서 그럼
오 감사합니다!