카테고리 없음
LookAt 메서드(오브젝트를 바라보게 함)
ruripanda
2024. 10. 15. 00:33
//bulletPrefab의 복제본을 transform.position 위치와 transform.rotation 회전으로 생성
GameObject bullet = Instantiate(bulletPrefab, transform.position, transform.rotation);
//생성된 bullet 게임 오브젝트의 정면 방향이 target을 향하도록 회전
bullet.transform.LookAt(target);
void Update에 주로 생성하며 어떤 대상을 상대로 바라보게 하는 메서드
주된 예는 플레이어를 적이 바라보게 하면서 접근하게 할 수 있음