GameDevelop/Unity팀프로젝트

[Unity] 몬스터 죽을 때 아이템 드롭 자연스럽게 배치하기

도도돋치 2025. 6. 1. 16:43
Contents 접기
728x90

구현목표

몬스터가 죽을 때 아이템이 한 자리에 겹쳐서 나오지 않도록 Offset을 이용하여 조금씩 떨어뜨렸다.

 

 

아이템 나란히 드롭 코드

for (int i = 0; i < dropOnDeath.Count; i++)
{
    Vector3 spawnOffset = new Vector3(1f * i, 0, 0); // x축으로 1씩 간격
    Vector3 spawnPosition = transform.position + spawnOffset;
    ItemDatabase.Instance.SpawnItem(spawnPosition, dropOnDeath[i]);
}

 

 

정리

  • 드롭 위치는 transform.position + offset 으로 조절
728x90