// Update is called once per frame void Update() { beatlePosition = new Vector3(transform.position.x, WorldHandler.CAMERA_Y, transform.position.z); // not sure if i should add a transform.hasChanged test so it doesnt call this every frame? timer += Time.deltaTime; if (health <= 0) { gameObject.SetActive(false); WorldHandler.unitsSelected.Remove(gameObject); isUnitSelected = false; WorldHandler.DestroyFlags(); GetComponent <Collider>().isTrigger = false; if (isServer) { WorldHandler.findLocalPlayer().GetComponent <WorldHandler>().Rpc_DespawnObject(gameObject); } } if (isUnitSelected) { displayBeatleInfo(); } if (beatlePosition != Vector3.zero) { // when space is pressed, move camera to the anthill if (Input.GetKey(KeyCode.Space) && isUnitSelected) { Camera.main.transform.position = beatlePosition; Debug.Log(beatlePosition); } } }
// Update is called once per frame void Update() { antPosition = new Vector3(transform.position.x, 43.2f, transform.position.z); // not sure if i should add a transform.hasChanged test so it doesnt call this every frame? timer += Time.deltaTime; if (health <= 0) { //gameObject.SetActive(false); WorldHandler.unitsSelected.Remove(gameObject); isUnitSelected = false; WorldHandler.DestroyFlags(); GetComponent <Collider>().isTrigger = false; localPlayer.Cmd_disableUnit(gameObject); } if (isUnitSelected) { displayAntInfo(); } if (antPosition != Vector3.zero) { // when space is pressed, move camera to the anthill if (Input.GetKey(KeyCode.Space) && isUnitSelected) { Camera.main.transform.position = antPosition; } } }
void OnMouseDown() // Change to OnMouseHover and check for clicks, then put a public static bool inside of dragselection script called "isDragging" if you are dragging none of this should apply { if (!EventSystem.current.IsPointerOverGameObject()) // If the mouse is not over an event system object (UI Object) and the user is pressing the left click { WorldHandler.deselectUnits(); WorldHandler.deselectAntHill(); Cursor.lockState = CursorLockMode.Confined; // lock the cursor when the user clicks the terrain. WorldHandler.hideAnthillInfo(); WorldHandler.DestroyFlags(); } }