private Vector3 CalcPositionOnCurve(float percent) { //pC = lerp between pA and handle Vector3 c = Powers_AnimMath.Lerp(positionA.position, handle.position, percent, true); Vector3 d = Powers_AnimMath.Lerp(handle.position, positionB.position, percent, true); Vector3 f = Powers_AnimMath.Lerp(c, d, percent, true); return(f); }
private Vector3 CalcPositionOnCurve(float percent) { Vector3 c = Powers_AnimMath.Lerp(positionA.position, handleA.position, percent, true); Vector3 d = Powers_AnimMath.Lerp(handleB.position, positionB.position, percent, true); Vector3 e = Powers_AnimMath.Lerp(handleA.position, handleB.position, percent, true); Vector3 f = Powers_AnimMath.Lerp(c, e, percent, true); Vector3 g = Powers_AnimMath.Lerp(e, d, percent, true); return(Powers_AnimMath.Lerp(f, g, percent, true)); }
private void ShakeCamera() { if (shakeIntensity < 0) { shakeIntensity = 0; } if (shakeIntensity > 0) { shakeIntensity -= Time.deltaTime * (4 * shakeIntensity); } else { return; //shake intensity is 0, do nothing. } Quaternion targetRot = Powers_AnimMath.Lerp(Random.rotation, Quaternion.identity, .999f); cam.transform.localRotation = Quaternion.Lerp(cam.transform.localRotation, Random.rotation, 0.001f * shakeIntensity); }
private void WiggleLegs() { float degrees = 45; float speed = 10; Vector3 inputDirLocal = transform.InverseTransformDirection(inputDirection); Vector3 axis = Vector3.Cross(inputDirLocal, Vector3.up); //check alignment of inputDirLocal against forward vector float alignment = Vector3.Dot(inputDirLocal, Vector3.forward); alignment = Mathf.Abs(alignment); //flips negative numbers degrees *= Powers_AnimMath.Lerp(0.25f, 1f, alignment, true); //decrease degrees when strafing float wave = Mathf.Sin(Time.time * speed) * degrees; legL.localRotation = Powers_AnimMath.Slide(legL.localRotation, Quaternion.AngleAxis(wave, axis), 0.001f); legR.localRotation = Powers_AnimMath.Slide(legR.localRotation, Quaternion.AngleAxis(-wave, axis), 0.001f); }
public static Vector2 Slide(Vector2 current, Vector2 target, float percentLeftAfter1Second) { float p = 1 - Mathf.Pow(percentLeftAfter1Second, Time.deltaTime); return(Powers_AnimMath.Lerp(current, target, p)); }
public static float Slide(float current, float target, float percentLeftAfter1Second) { float p = 1 - Mathf.Pow(percentLeftAfter1Second, Time.deltaTime); return(Powers_AnimMath.Lerp(current, target, p, true)); }
private void DoTheLerp() { transform.position = Powers_AnimMath.Lerp(objectStart.transform.position, objectEnd.transform.position, percent, true); }
// Update is called once per frame void LateUpdate() { transform.position = Powers_AnimMath.Lerp(pointA.position, pointB.position, percent, false); transform.position = Powers_AnimMath.Lerp(pointA.position, pointB.position, percent, false); }
void Update() { //Check if player is holding down right click if (Input.GetMouseButton(1) && !tutCompleted) { //Get mouse movement camDirection.x -= Input.GetAxis("Mouse Y"); camDirection.y += Input.GetAxis("Mouse X"); //If player has moved mouse, complete tutorial if (camDirection.magnitude > 5f) { tutCompleted = true; } } if (tutCompleted) { //If tut alpha is not 0, lerp it towards 0. if (tutAlpha != 0) { //Set tut alpha to current image alpha tutAlpha = tutImage.color.a; //Lerp alpha down to 0 if not close, otherwise set to 0 if (tutAlpha > 0.01f) { tutAlpha = Powers_AnimMath.Lerp(tutImage.color.a, 0, 0.05f, false); } else { tutAlpha = 0; } //Set image color alpha to temp alpha tutImage.color = new Color(tutImage.color.r, tutImage.color.g, tutImage.color.b, tutAlpha); } //If image color alpha is 0 and canvas group alpha is not 1, start work on norm UI alpha. else if (tutImage.color.a == 0 && normalUIcanvas.alpha != 1) { //activate normal ui holder. this was to prevent sfx from playing before the transition starts. normalUI.SetActive(true); //Set tut alpha to current image alpha normAlpha = normalUIcanvas.alpha; //Lerp alpha down to 0 if not close, otherwise set to 0 if (normAlpha < 0.99f) { normAlpha = Powers_AnimMath.Lerp(normalUIcanvas.alpha, 1, 0.05f, false); } else { normAlpha = 1; } //Set image color alpha to temp alpha normalUIcanvas.alpha = normAlpha; } //If normal UI alpha is now 1, the tut is complete. Set canvas group interactable to true and destroy this. else if (tutImage.color.a == 0 && normalUIcanvas.alpha == 1) { normalUIcanvas.interactable = true; Destroy(this); } } }