private void ChangeToMeltMaterial(GameObject obj) { Material currMaterial = obj.GetComponent <Renderer>().material; if (currMaterial) { Color color = currMaterial.GetColor("_Color"); Texture albedo = currMaterial.GetTexture("_MainTex"); Texture normals = currMaterial.GetTexture("_BumpMap"); currMaterial.shader = meltShader; currMaterial.SetColor("_Color", color); currMaterial.SetFloat("_MeltY", suckingPoint.position.y); currMaterial.SetVector("_MeltPosition", suckingPoint.position); currMaterial.SetTexture("_NormalTex", normals); currMaterial.SetTexture("_MainTex", albedo); Collider[] pinaColada = obj.GetComponents <Collider>(); foreach (Collider cocktail in pinaColada) { cocktail.enabled = false; } Rigidbody warmBeer = obj.GetComponent <Rigidbody>(); warmBeer.drag = 0f; warmBeer.angularDrag = 0f; warmBeer.useGravity = false; warmBeer.isKinematic = false; warmBeer.constraints = RigidbodyConstraints.None; Sucked suckedIn = obj.AddComponent <Sucked>(); suckedIn.finalPosition = obj.transform.position - Vector3.up * 2.5f; suckedIn.suckDirection = transform; suckedIn.speedCoefficient = 0.5f; } }
private void ChangeToMeltMaterial(GameObject obj) { Material currMaterial = obj.GetComponent <Renderer>().material; if (currMaterial) { Color color = currMaterial.GetColor("_Color"); Texture albedo = currMaterial.GetTexture("_MainTex"); Texture normals = currMaterial.GetTexture("_BumpMap"); currMaterial.shader = meltShader; currMaterial.SetColor("_Color", color); currMaterial.SetFloat("_MeltY", suckingPoint.position.y); currMaterial.SetVector("_MeltPosition", suckingPoint.position); currMaterial.SetTexture("_NormalTex", normals); currMaterial.SetTexture("_MainTex", albedo); obj.GetComponent <Collider>().enabled = false; obj.GetComponent <Rigidbody>().useGravity = false; Sucked suckedIn = obj.AddComponent <Sucked>(); suckedIn.finalPosition = obj.transform.position - Vector3.up * 2.5f; suckedIn.suckDirection = transform; } }