IEnumerator PrintPart(GameObject shipModule) { foreach (ParticleSystem particleSystem in printParticles) { particleSystem.Play(); } yield return(new WaitForSeconds(0.2f)); newPart = Instantiate(shipModule, printPoint.position, printPoint.rotation).GetComponent <ShipModule>(); SceneManager.instance.AddGravityBody(newPart.GetComponent <Rigidbody>()); newPart.Dematerialize(PartPrinterData.instance.printMaterial); meshRenderer = newPart.GetComponent <MeshRenderer>(); SetPartOpacity(partOpacity); yield return(new WaitForSeconds(PartPrinterData.instance.printTime)); foreach (ParticleSystem particleSystem in printParticles) { particleSystem.Stop(); } yield return(new WaitForSeconds(0.2f)); newPart.Materialize(); newPart = null; partOpacity = 0f; }
void SnapModule() { if (Vector3.Distance(connectedModule.transform.localPosition, Vector3.zero) > 0.05f || Quaternion.Angle(connectedModule.transform.localRotation, Quaternion.identity) > 1f) { connectedModule.transform.localPosition = Vector3.Lerp(connectedModule.transform.localPosition, Vector3.zero, moduleSnapSpeed * Time.fixedDeltaTime); connectedModule.transform.localRotation = Quaternion.Slerp(connectedModule.transform.localRotation, Quaternion.identity, moduleSnapSpeed * Time.fixedDeltaTime); } else { if (!connectedModule.IsMaterialized()) { connectedModule.transform.localPosition = Vector3.zero; connectedModule.transform.localRotation = Quaternion.identity; connectedModule.Materialize(); } } }