Hello how do i make it where i instantiate an object but when i instantiate another object it deletes the previous one, does anyone know how to do this(in C#)??
You would need a reference to the previous object, and then do a Destroy() with the previous object. An example might be something like:
private GameObject currentInstantiatedObject;
void Spawn()
{
//Destroy the previous object if there is one
if(currentInstantiatedObject != null)
Destroy(currentInstantiatedObject)
//Instantiate the object
GameObject spawnedObject = Instantiate(prefab, spawnPosition, Quaternion.identity) as GameObject;
//Set the current object to this spawned object, so it can be destroyed next spawn.
currentInstantiatedObject = spawnedObject;
}