make an object disappear and another object appear...

Hi, First time asker… anyway, i’m aware that if you want to make a game object “disappear” you can use something like a “.active = false” command, but is there any way to make a gameobject disappear and then make a different gameobject appear simultaneously? (basically in the same click)

A simple way is to have references to both objects in a control script attached to a 3rd object - like this:

var object1: GameObject;
var object2: GameObject;
private var hide1show2 = false; // hide object1 when true, object2 otherwise

function HideShow(){ // hide/show objects
  object1.SetActive(!hide1show2);
  object2.SetActive(hide1show2);
}

function Start(){
  HideShow(); // apply hide1show2 at Start
}

function Update(){
  if (Input.GetKeyDown("h")){ // if H pressed...
    hide1show2 = !hide1show2; // toggle hide1show2
    HideShow(); // apply the new hide1show2 state
  }
}

This script should be attached to any object but the ones you want to hide/show - like the camera or an empty object.