private void OnHoleGenerated(Transform hole, Transform holeWall) { holeWall.localScale = new Vector3(1, 50, 1); // Less shaking for holes farther from camera var distance = Vector3.Distance(Camera.main.transform.position, holeWall.position); var percentageDistance = Mathf.Clamp01((distance - minD) / (maxD - minD)); var distanceFromCameraPenalty = (1 - percentageDistance) * 1.2f; var shapeLength = MyMaths.ShapeLength(hole.GetComponent <MeshFilter>().mesh.vertices); var lenghtBonus = 1 + (Mathf.Clamp01((shapeLength - minL) / (maxL - minL)) * .5f); // Debug.Log($"shapeLength={shapeLength} lenghtBonus={lenghtBonus} distance={distance} distanceFromCameraPenalty={distanceFromCameraPenalty}"); Sequence sequence = DOTween.Sequence(); sequence.AppendCallback(() => { holeWall.gameObject.SetActive(true); Signals.Get <ShakeCameraSignal>().Dispatch(beamDuration, shakeMagnitude * distanceFromCameraPenalty * lenghtBonus); hole.gameObject.SetActive(true); }); sequence.AppendInterval(beamDuration); sequence.AppendCallback(() => { holeWall.gameObject.SetActive(false); }); sequence.AppendCallback(() => { var mat = hole.GetComponent <Renderer>().material; DOVirtual.Float(.05f, 1, 2.5f, (percentage) => { var eased = DOVirtual.EasedValue(0, 1, percentage, Ease.OutQuad); mat.SetFloat(SliceAmount, eased); }); }); }