Prefab Instancing

I’m trying to build a script that appends a volume(cube)once you enter the next volume and then destroys the volume that you’ve left. I’m somewhat new to Javascript so the more help I can get would be great!

So it would look something like: [P]
Then the next iteration would be: [P]

X=destroyed prefab
P=prefab that player is within
=empty volumes

The volume would have a Box Collider on it, set to ‘is trigger’ and script would implement OnTriggerExit() which would call Destroy(gameObject);

Ok, so it’s building a gridlike structure, and the volumes can be appended in any direction except backwards, would I use vectors to define which direction the “rules” say that I can append certain volumes to certain volumes?