I’ve had this idea for a puzzle game and right now I’m trying to make it to when I step on a button a cube spawns. The issue though is I want that every time i step on the button the cube respawns. kinda like the cubes in the portal games.
the script that I’m using:
bool hasSpawned = false;
public GameObject Box;
public GameObject boxSpawner;
void OnTriggerEnter(Collider other)
{
if (!hasSpawned)
{
hasSpawned = true;
Instantiate(Box, boxSpawner.transform);
}
if (hasSpawned)
{
Destroy(Box);
Instantiate(Box, boxSpawner.transform);
}
}
}