2025-01-28

John Jean·2025년 1월 28일

Unity

목록 보기
11/19

Physics Materials

개별 콜라이더에 Rigidbody와는 다른 물리효과를 줄 수 있다.

Lane Pickups


List<int> availableLanes = new List<int> { 0, 1, 2 };

private void Start()
{
    SpawnFences();
    spawnApple();
    spawnCoin();
}

void SpawnFences()
{
    int fencesToSpawn = Random.Range(0, lanes.Length);

    for(int i = 0; i < fencesToSpawn; i++)
    {
        if (availableLanes.Count <= 0) break;
        int selectedLane = SelectLane();

        Vector3 spawnPosition = new Vector3(lanes[selectedLane], transform.position.y, transform.position.z);
        Instantiate(fencePrefab, spawnPosition, Quaternion.identity, this.transform);
    }
}
void spawnApple()
{
    if(Random.value > appleSpawnChance) return;
    if (availableLanes.Count <= 0) return;
    int selectedLane = SelectLane();

    Vector3 spawnPosition = new Vector3(lanes[selectedLane], transform.position.y, transform.position.z);
    Instantiate(applePrefab, spawnPosition, Quaternion.identity, this.transform);
}

배열을 써서 생성할 수도 있음.

profile
크래프톤 6기 정글러

0개의 댓글