Exemplo n.º 1
0
    private void Update()
    {
        speedMultiplier = Mathf.Lerp(speedMultiplier, targetSpeed, Time.deltaTime * SpeedDelta);

        //camera shake looks bugged in slowmo :D
        if (TimeScaler.Unconventional)
        {
            ShakeMagnitude = 0f;
        }

        if (ShakeMagnitude > 0.01f)
        {
            shakeTimer += Time.deltaTime;

            if (shakeTimer >= shakeTime)
            {
                shakeTimer = 0f;
                shakeTime  = Random.Range(ShakeFrequency.x, ShakeFrequency.y);
                float x = (Random.value * 2 - 1);
                float y = (Random.value * 2 - 1);
                AxMath.SafeNormalize(ref x, ref y);
                transform.position += (Vector3)(new Vector2(x, y) * ShakeModulus * ShakeMagnitude);
                ShakeMagnitude     *= ShakeDecay;
            }
        }

        transform.rotation = Quaternion.Slerp(transform.rotation, Quaternion.Euler(0, 0, targetRotation), Time.deltaTime * RotationSpeed * speedMultiplier);
        Vector3 target = targetPosition + targetVelocity * Prediction;

        transform.position = Vector3.Lerp(transform.position, target + offset, Time.deltaTime * MoveSpeed * speedMultiplier);
    }