MissingReferenceException: The object of type 'GameObject' has been destroyed but you are still trying to access it. Your script should either check if it is null or you should not destroy the object.


collider๋ผ๋ฆฌ ๋ถ€๋”ชํžˆ๋ฉด ๊ฒŒ์ž„ ์˜ค๋ฒ„๋กœ ํ•ด๋†“๊ณ  ํŠน์ • ์˜ค๋ธŒ์ ํŠธ๋ผ๋ฆฌ๋Š” ๊ฐ™์€ ๋ ˆ์ด์–ด๋กœ ์„œ๋กœ ์ถฉ๋Œํ•˜์ง€ ์•Š๊ฒŒ ํ–ˆ์Œ

์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ๊ธฐ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ ์ดˆ๋‹น ์ƒ์„ฑ์ธ๋ฐ 3~4๊ฐœ ํ•œ๊บผ๋ฒˆ์— ๋‚˜์˜ด

๊ทธ๋ฆฌ๊ณ  ์˜ค๋ธŒ์ ํŠธ ์œ„์น˜ ํšŒ์ „์‹œํ‚ค๋Š” ๋ฒ„ํŠผ ๋งŒ๋“ค์—ˆ๋Š”๋ฐ ํด๋ก ์€ ์กฐ์ข…์ด ์•ˆ๋จ

์œ„์— ๋ง ์ดˆ๋‹น 200๊ฐœ์”ฉ ๋œธ

์กฐ์–ธ ๊ตฌํ•ฉ๋‹ˆ๋‹ค..

(์˜ค๋ธŒ์ ํŠธ ์ƒ์„ฑ๊ธฐ๋„ ์ด์ƒํ•˜๊ฒŒ ๋งŒ๋“ ๋“ฏ) ๋ฐ‘์— ์ฝ”๋”ฉ



using System.Collections;

using System.Collections.Generic;

using UnityEngine;


public class generator : MonoBehaviour

{

public GameObject red,blue,green,yellow;

public float timediff;

float timer = 0;


void Update()

{

timer += Time.deltaTime;

if (timer > timediff)

{

Instantiate(red);

Instantiate(blue);

Instantiate(green);

Instantiate(yellow);


timer = 0;

}

}

}

ํ˜น์‹œ ์ผ์ • ์‹œ๊ฐ„๋งˆ๋‹ค ๋žœ๋ค ์˜ค๋ธŒ์ ํŠธ ๋ฐœ์‚ฌ (์ ์ˆ˜ ์˜ค๋ฅผ์ˆ˜๋ก ๋น ๋ฅธ ์†๋„) ์ด๊ฑฐ ์•Œ๋ ค์ฃผ์‹ค ๋ถ„..