Unity 2019.2.18f1
So, I'm trying to spawn in an item whenever the trigger is entered. It seems to work but it also crashes Unity almost instantly. It's hard to tell but looks like Unity is making multiple of these objects and that's causing the crash. How do I fix this?
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CreateObject : MonoBehaviour
{
public Transform Spawnpoint;
public GameObject Prefab;
private void OnTriggerEnter(Collider other)
{
Instantiate(Prefab, Spawnpoint.position, Spawnpoint.rotation);
}
}
↧