void bigGuyJump() { float height = Mathf.PerlinNoise(jumpIter, 0f) * 10f; height = height * height * 0.3f; // Debug.Log("height:"+height+" jumpIter:"+jumpIter); LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() => { LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete(() => { LeanTween.cancel(gameObject); /************** * Camera Shake **************/ float shakeAmt = height * 0.2f; // the degrees to shake the camera float shakePeriodTime = 0.42f; // The period of each shake float dropOffTime = 1.6f; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(Vector3.right * val); } ).setEase(LeanTweenType.easeOutQuad); /******************** * Shake scene objects ********************/ // Make the boxes jump from the big stomping GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn"); // I just arbitrarily tagged the boxes with this since it was available in the scene foreach (GameObject box in boxes) { box.rigidbody.AddForce(Vector3.up * 100 * height); } // Make the lamps spin from the big stomping GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController"); // I just arbitrarily tagged the lamps with this since it was available in the scene foreach (GameObject lamp in lamps) { float z = lamp.transform.eulerAngles.z; z = z > 0.0f && z < 180f ? 1 : -1; // push the lamps in whatever direction they are currently swinging lamp.rigidbody.AddForce(new Vector3(z, 0f, 0f) * 15 * height); } // Play BOOM! playAudio(boomAudioClip, transform.position, height * 0.2f, 0.34f); // Have the jump happen again 2 seconds from now LeanTween.delayedCall(2f, bigGuyJump); }); }); jumpIter += 5.2f; }
protected virtual void Punch(Vector3 axis, float intensity, float time) { GameObject go = punchObject; if (go == null) { go = Camera.main.gameObject; } if (go != null) { float shakePeriodTime = 0.42f; // The period of each shake LTDescr shakeTween = LeanTween.moveLocal(gameObject, axis * intensity, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(punchObject, intensity, 0f, time).setOnUpdate( (float val) => { shakeTween.setTo(axis * val); } ).setEase(LeanTweenType.easeInQuart); } }
public void ScreenShake() { /************** * Camera Shake **************/ if (!LeanTween.isTweening(camx.gameObject)) { float height = Mathf.PerlinNoise(jumpIter, 0f) * 5f; height = height * height * 0.2f; float shakeAmt = height * 0.9f; // the degrees to shake the camera float shakePeriodTime = 0.2f; // The period of each shake float dropOffTime = 0.3f; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.rotateAroundLocal(camx.gameObject, Vector3.right, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(camx.gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(Vector3.right * val); } ).setEase(LeanTweenType.easeOutQuad).setOnComplete( () => { LeanTween.cancel(camx.gameObject); camx.transform.rotation = Quaternion.identity; }); } }
void bigGuyJump() { float height = Mathf.PerlinNoise(jumpIter, 0f) * 10f; height = height * height * 0.3f; // //Debug.Log("height:"+height+" jumpIter:"+jumpIter); LeanTween.moveY(avatarBig, height, 1f).setEase(LeanTweenType.easeInOutQuad).setOnComplete(() => { LeanTween.moveY(avatarBig, 0f, 0.27f).setEase(LeanTweenType.easeInQuad).setOnComplete(() => { LeanTween.cancel(gameObject); /************** * Camera Shake **************/ float shakeAmt = height * 0.2f; // the degrees to shake the camera float shakePeriodTime = 0.42f; // The period of each shake float dropOffTime = 1.6f; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(Vector3.right * val); } ).setEase(LeanTweenType.easeOutQuad); /******************** * Shake scene objects ********************/ // Make the boxes jump from the big stomping GameObject[] boxes = GameObject.FindGameObjectsWithTag("Respawn"); // I just arbitrarily tagged the boxes with this since it was available in the scene foreach (GameObject box in boxes) { box.GetComponent <Rigidbody>().AddForce(Vector3.up * 100 * height); } // Make the lamps spin from the big stomping GameObject[] lamps = GameObject.FindGameObjectsWithTag("GameController"); // I just arbitrarily tagged the lamps with this since it was available in the scene foreach (GameObject lamp in lamps) { float z = lamp.transform.eulerAngles.z; z = z > 0.0f && z < 180f ? 1 : -1; // push the lamps in whatever direction they are currently swinging lamp.GetComponent <Rigidbody>().AddForce(new Vector3(z, 0f, 0f) * 15 * height); } // Play BOOM! LeanAudio.play(boomAudioClip, transform.position, height * 0.2f); // Like this sound? : http://leanaudioplay.dentedpixel.com/?d=a:fvb:8,0,0.003005181,0,0,0.01507768,0.002227979,0,0,8~8,8.130963E-06,0.06526042,0,-1,0.0007692695,2.449077,9.078861,9.078861,0.01541314,0.9343268,-40,-40,0.05169491,0.03835937,-0.08621139,-0.08621139,8~0.1,0,0,~44100 // Have the jump happen again 2 seconds from now LeanTween.delayedCall(2f, bigGuyJump); }); }); jumpIter += 5.2f; }
public void ShakeCamera(Vector3 side, bool isUp) { LeanTween.cancel(gameObject); transform.localRotation = Quaternion.Euler(Vector3.zero); float height = Mathf.PerlinNoise(force1, 0f) * force2; height = height * height * 0.3f; /************** * Camera Shake **************/ float shakeAmt = height * 0.2f * (isUp ? -1 : 1); // the degrees to shake the camera LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, side, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(gameObject, shakeAmt, 0f, time).setOnUpdate( (float val) => { shakeTween.setTo(side * val); } ).setEase(LeanTweenType.easeOutQuad); // Play BOOM! LeanAudio.play(boomAudioClip, transform.position, height * 0.2f); // Like this sound? : http://leanaudioplay.dentedpixel.com/?d=a:fvb:8,0,0.003005181,0,0,0.01507768,0.002227979,0,0,8~8,8.130963E-06,0.06526042,0,-1,0.0007692695,2.449077,9.078861,9.078861,0.01541314,0.9343268,-40,-40,0.05169491,0.03835937,-0.08621139,-0.08621139,8~0.1,0,0,~44100 }
public void ShowSignIn() { Tracker.ScreenVisit(SCREEN_NAME.SIGN_IN); #if PLAY_STORE || UNITY_IOS || UNITY_TVOS Social.localUser.Authenticate((bool success) => { isSignedIn = success; DataStorage.IgnoreSignIn = !success; if (!success) { if (signInFailedEffect) { return; } signInFailedEffect = true; float shakeAmount = 20; float shakePeriodTime = .25f; LTDescr shakeTween = LeanTween.rotateAroundLocal(buttons[0].gameObject, Vector3.forward, shakeAmount, shakePeriodTime) .setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1); LeanTween.value(buttons[0].gameObject, shakeAmount, 0f, 2).setOnUpdate((float val) => { shakeTween.setTo(Vector3.right * val); }).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => { signInFailedEffect = false; }); return; } buttons[0].gameObject.SetActive(false); buttons[1].gameObject.SetActive(true); }); #endif }
public void Shake() { float height = Mathf.PerlinNoise(jumIter, 0f) * 5; height = height * height * 0.2f; float shakeAmt = height; // degrees to shake the camera float shakePeriodTime = 0.25f; // period of each shake float dropOffTime = 1.25f; // how long it takes to settle down to nothing LTDescr shakeTween = LeanTween .rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) .setLoopClamp() .setRepeat(-1); LeanTween.value(gameObject, shakeAmt, 0, dropOffTime) .setOnUpdate((float val) => { shakeTween.setTo(Vector3.right * val); }) .setEase(LeanTweenType.easeOutQuad); }
public void shakeAndBake() { float shakeAmt = 1f; // the degrees to shake the camera float shakePeriodTime = 0.42f; // The period of each shake float dropOffTime = 1.6f; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.forward, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(Vector3.right * val); } ).setEase(LeanTweenType.easeOutQuad); }
void stopShake() { LeanTween.value(gameObject, 1f, 4.0f, 2.0f).setOnUpdate( (float val) => { //tween1.setTime(val*0.2f); tween2.setTime(val * 0.25f); //tween1.setTo(Vector3.up*val); tween2.setTo(Vector3.right * (1.0f / val)); } ).setEase(LeanTweenType.easeInSine).setOnComplete( () => { //tween1.setRepeat(1); tween2.setRepeat(1); Debug.Log("finished"); } ); }
protected void ShakePanel(object parameters) { // Parameters: RectTransform panel, Vector3 direction, float amount object[] parameterList = parameters as object[]; RectTransform panel = (RectTransform)parameterList[0]; Vector3 direction = (Vector3)parameterList[1]; float amount = (float)parameterList[2]; // Check if we have a callback, sometimes this will be needed OnShakePanelComplete shakePanelComplete = null; if (parameterList.Length > 3) { shakePanelComplete = (OnShakePanelComplete)parameterList[3]; } // Setup Shake Properties float forceJump = 9.5f; float height = Mathf.PerlinNoise(forceJump, 0f) * amount; height = height * height * 0.3f; float shakeAmt = height * 0.2f; // the degrees to shake the camera float shakePeriodTime = 0.32f; // The period of each shake float dropOffTime = 1.25f; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.moveLocal(panel.gameObject, direction * 1.5f, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the camera shake down to zero LeanTween.value(panel.gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(direction * val); } ).setEase(LeanTweenType.easeOutQuad).setOnComplete(() => { if (shakePanelComplete != null) { shakePanelComplete(); } }); }
public static void Shake(this GameObject gameObject, float force = 10f, float jump = 9.5f, float easeOff = 1.6f, float time = 0.42f) { float height = Mathf.PerlinNoise(jump, 0f) * force; height = height * height * 0.3f; float shakeAmt = height * 0.2f; // the degrees to shake float shakePeriodTime = time; // The period of each shake float dropOffTime = easeOff; // How long it takes the shaking to settle down to nothing LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime) .setEase(LeanTweenType.easeShake) // this is a special ease that is good for shaking .setLoopClamp() .setRepeat(-1); // Slow the shake down to zero LeanTween.value(gameObject, shakeAmt, 0f, dropOffTime).setOnUpdate( (float val) => { shakeTween.setTo(Vector3.right * val); } ).setEase(LeanTweenType.easeOutQuad); }
public void Shake() { float height = Mathf.PerlinNoise(jumpIterator, 0) * 5; height = height * height * 0.2f; //Degrees to shake the camera float shakeAmount = height; //Period of each shake float shakePeriodOfTime = 0.25f; //How long it takes for the shaking to stop float dropOffTime = 1.25f; //No idea what this stuff does LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmount, shakePeriodOfTime).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1); LeanTween.value(gameObject, shakeAmount, 0, dropOffTime).setOnUpdate((float val) => { shakeTween.setTo(Vector3.right * val); }).setEase(LeanTweenType.easeOutQuad); }
public float jumpIter = 4.5f; // Koliko jako ce se kamera tresti public void Shake() { float height = Mathf.PerlinNoise(jumpIter, 0f) * 5; height = height * height * 0.2f; float shakeAmt = height; // * 0.01f; // stupnjevi po kojima se kamera trese float shakePeriodTime = 0.25f; // period float dropOffTime = 1.25f; // koliko dugo treba da se stabilizira LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1); // LeanTween ce koristiti easeShake od sve dok shakeAmt ne postane 0, a trebat ce 1.25 sekundi LeanTween.value(gameObject, shakeAmt, 0, dropOffTime).setOnUpdate(( float val ) => { shakeTween.setTo(Vector3.right * val); }).setEase(LeanTweenType.easeOutQuad); }
public void Shake() { float height = Mathf.PerlinNoise(jumpIter, 0f) * 5; height = height * height * 0.2f; float shakeAmt = height; float shakePeriodTime = 0.25f; float dropOffTime = 1.25f; LTDescr shakeTween = LeanTween.rotateAroundLocal(gameObject, Vector3.right, shakeAmt, shakePeriodTime).setEase(LeanTweenType.easeShake).setLoopClamp().setRepeat(-1); LeanTween.value(gameObject, shakeAmt, 0, dropOffTime).setOnUpdate(( float val ) => { shakeTween.setTo(Vector3.right * val); }).setEase(LeanTweenType.easeOutQuad); }