void Update() { if (!GameState.isInCreatorMode) { return; } if (saveScreen.activeInHierarchy) { return; } ray = Camera.main.ScreenPointToRay(Input.mousePosition); hasHitAPotentialTarget = Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << LayerMask.NameToLayer("Block")); if (Input.GetMouseButtonDown(1) && hasHitAPotentialTarget) { if (hit.collider.transform.tag != "Core") { Destroy(hit.collider.transform.gameObject); } } if (currentlySelectedBlock == null) { return; } if (hasHitAPotentialTarget) { if (prefabUtils.blocks[currentlySelectedBlockIndex].GetComponent <BoxCollider>() != null) { Vector3 newPosition = GetPosition(); if (prefabUtils.blocks[currentlySelectedBlockIndex].transform.GetComponent <ZeroGBlock>() != null) { // Check if there's nothing under the zero gravity module we want to put if (Physics.Raycast(newPosition, Vector3.down, prefabUtils.GetExtents(currentlySelectedBlockIndex).y + 0.5f)) { currentlySelectedBlock.SetActive(false); return; } } if (prefabUtils.blocks[currentlySelectedBlockIndex].transform.GetComponent <BoostBlock>() != null) { // Check if there's nothing behind the boost module we want to put if (Physics.Raycast(newPosition, -transform.forward, prefabUtils.GetExtents(currentlySelectedBlockIndex).z + 0.5f)) { currentlySelectedBlock.SetActive(false); return; } } // Makes sure we do not something under a zero gravity module if (hit.collider.GetComponentInChildren <ZeroGBlock>() != null || hit.collider.GetComponentInChildren <BoostBlock>() != null) { currentlySelectedBlock.SetActive(false); return; } instantiateCenter = GetPosition(); Collider[] overlapColliders = Physics.OverlapBox(instantiateCenter, prefabUtils.GetExtents(currentlySelectedBlockIndex) * 0.95f); if (overlapColliders.Length > 0) { currentlySelectedBlock.SetActive(false); return; } // Show the position where the block will be put currentlySelectedBlock.transform.position = newPosition; currentlySelectedBlock.transform.rotation = Quaternion.identity; currentlySelectedBlock.SetActive(true); if (Input.GetMouseButtonDown(0)) { // Put the selected block on the vehicle currentlySelectedBlock.GetComponent <BoxCollider>().enabled = true; Color oldColor = currentlySelectedBlock.GetComponent <MeshRenderer>().material.color; currentlySelectedBlock.GetComponent <MeshRenderer>().material.color = new Color(oldColor.r, oldColor.g, oldColor.b, 1.0f); currentlySelectedBlock.GetComponent <Bloc>().data.position = currentlySelectedBlock.transform.position; currentlySelectedBlock.GetComponent <Bloc>().data.rotation = currentlySelectedBlock.transform.rotation; // Create a new preview block CreatePreviewBlock(); } } } else { // Deactivate preview if no potential target currentlySelectedBlock.SetActive(false); } freelookCameraCreator.m_XAxis.Value += -Input.GetAxisRaw("Horizontal"); Camera.main.transform.LookAt(vehicle.transform); for (int i = 0; i < 3; i++) { freelookCameraCreator.m_Orbits[i].m_Radius = Mathf.Clamp(freelookCameraCreator.m_Orbits[i].m_Radius - Input.GetAxisRaw("Mouse ScrollWheel") * mouseScrollSensitivity, 7, 40); } }