5-4) Spawning Diamonds Randomly

시그니천·2024년 6월 8일

[ G01 ] ZigZagRacer

목록 보기
25/26

1. gizmos 꺼놓기

2. scene에있는 diamond SetActive(false);

3. platform.cs

public gameObject diamond;
void Start()
{
    int randDiamond = Random.Range(0,5);
    
    Vector3 diamondPos = transform.position;
    diamondPos.y += 1f;
    
    if(randDiamond < 1)
    {
       // spawn the diamond
       Instantiate(diamond, diamondPos, diamond.transform.rotation);
    }
    // 1 2 3 4 Dont't spawn the diamond
}

4. Drag & Drop

profile
우주최강개발자

0개의 댓글