void Update() { cachedTransform.position -= Vector3.up * Time.deltaTime * cachedFallingSpeed; if (cachedTransform.position.y < cam.position.y - 5f) { cachedTransform.localPosition = Vector3.zero; mf.sharedMesh = manager.GetPreGennedMesh();//change rain pattern periodically } cachedTransform.rotation = rotation;//keep the rain always falling vertically instead of rotating with camera(parent) cachedTransform.localScale = new Vector3(rainSparsity, rainSparsity, rainSparsity); }
void Start() { manager = transform.parent.GetComponent <RainManager> (); bounds = new Bounds(new Vector3(transform.position.x, manager.minYPosition, transform.position.z), new Vector3(manager.areaSize * 1.35f, Mathf.Max(manager.areaSize, manager.areaHeight) * 1.35f, manager.areaSize * 1.35f)); mf = GetComponent <MeshFilter> (); mf.sharedMesh = manager.GetPreGennedMesh(); cachedTransform = transform; cam = transform.parent.transform; cachedMinY = manager.minYPosition; cachedAreaHeight = manager.areaHeight; cachedFallingSpeed = manager.fallingSpeed; }
void Start() { manager = transform.parent.GetComponent<RainManager>(); bounds = new Bounds(new Vector3(transform.position.x, manager.minYPosition, transform.position.z), new Vector3(manager.areaSize * 1.35f, Mathf.Max(manager.areaSize, manager.areaHeight) * 1.35f, manager.areaSize * 1.35f)); mf = GetComponent<MeshFilter>(); mf.sharedMesh = manager.GetPreGennedMesh(); cachedTransform = transform; cachedMinY = manager.minYPosition; cachedAreaHeight = manager.areaHeight; cachedFallingSpeed = manager.fallingSpeed; enabled = false; }