void Update() { if (target != null) { transform.position = MathStuff.Damp(transform.position, target.position, .1f); } }
private void EasePositionRotationScale() { float percentRemainingAfter1Second = .001f; //rt.localRotation = MathStuff.Damp(transform.localRotation, targetRotation, percentRemainingAfter1Second); rt.anchoredPosition = MathStuff.Damp(rt.anchoredPosition, targetPosition, percentRemainingAfter1Second); transform.localScale = Vector3.one * MathStuff.Damp(transform.localScale.x, targetScale, percentRemainingAfter1Second); }
void FixedUpdate() { if (target) { // move the camera-target towards the target car's position: float distanceAboveCar = 1; transform.position = MathStuff.Damp(transform.position, target.transform.position + new Vector3(0, distanceAboveCar, 0), 0f, Time.fixedDeltaTime); // calculate a distanceMultiplier from velocity float p = 1; if (target.ballBody) { p = Mathf.Clamp(target.ballBody.velocity.z / maxSpeed, 0, 1); } if (target && target.boost && target.boost.isBoosting) { p = 1; } p = Mathf.Clamp(p, 0, 1); p = cameraDistanceCurve.Evaluate(p); cameraDistance = Mathf.Lerp(cameraDistanceMin, cameraDistanceMax, p); cameraDistance = Mathf.Lerp(cameraDistance, cameraDistance * 4, target.driver.wantsToAim?1:0); cameraAngle = Mathf.Lerp(cameraAngleMin, cameraAngleMax, p); // CAMERA SHAKE: cameraPitch = 30; if (target && target.boost && target.boost.isBoosting) { float amp = 10 * target.ballBody.velocity.z / maxSpeed; cameraPitch += Random.Range(-amp, amp); } } if (cam) // zoom camera in or out: { Vector3 localPositionTarget = new Vector3(0, 0, -cameraDistance); cam.transform.localPosition = MathStuff.Damp(cam.transform.localPosition, localPositionTarget, .1f, Time.fixedDeltaTime); pitchControl.localRotation = MathStuff.Damp(pitchControl.localRotation, Quaternion.Euler(cameraPitch, 0, 0), .1f, Time.fixedDeltaTime); cam.fieldOfView = MathStuff.Damp(cam.fieldOfView, cameraAngle, .5f, Time.fixedDeltaTime); } }
void Update() { if (Game.isPaused) { return; } if (cooldownBeforeAttacking > 0) { cooldownBeforeAttacking -= Time.deltaTime; } else if (wantsToAttack) { Attack(); } transform.rotation = MathStuff.Damp(transform.rotation, lookDirection, rotationDampening); if (CurrentTome().updatedSinceLastRecalcPawnValues) { RecalculateValuesFromTome(); } }
private Vector3 DecelerateHorizontal(Vector3 velocity) { velocity.x = MathStuff.Damp(velocity.x, .01f, Time.fixedDeltaTime); return(velocity); }