public void StartState() { //First time if (portal_controller == null) { if (cosmo.cooldown_inst.AbilityIsReady(2) == true) //The ability is ready { portal_controller = GameObject.Instantiate(cosmo.portal_controller_prefab) as PortalController; //Create the controller portal_controller.cosmo_portal_controller = this; } else //The ability is still in cooldown { ToIdleState(); return; } } else { //Both portals are already created? if (portal_controller.ConnectionFinished()) { ToIdleState(); return; } } //Create build guide build_portal = GameObject.Instantiate(cosmo.build_portal_prefab) as GameObject; build_portal_mat = build_portal.GetComponent <MeshRenderer>().material; if (AbleToBuild()) { build_portal_mat.color = build_zone_col; } else { build_portal_mat.color = no_build_col; } }