Ejemplo n.º 1
0
    private void Update()
    {
        if (Mathfs.Approximately(_targetIntensity, _light.intensity))
        {
            // We reached our intensity, pick a new one
            _targetIntensity = Freya.Random.Range(minIntensity, maxIntensity);
        }

        if (Mathfs.DistanceSquared(_targetPos, transform.position) < 0.01f)
        {
            // We reached our position, pick a new one
            var tarX = Freya.Random.Range(_rootPosition.x - posVariance, _rootPosition.x + posVariance);
            var tarY = Freya.Random.Range(_rootPosition.y - posVariance, _rootPosition.y + posVariance);
            var tarZ = Freya.Random.Range(_rootPosition.z - posVariance, _rootPosition.z + posVariance);

            _targetPos = new Vector3(tarX, tarY, tarZ);
        }

        _light.intensity = Mathfs.MoveTowards(_light.intensity, _targetIntensity, intensitySpeed * Time.deltaTime);

        _light.transform.position =
            Vector3.MoveTowards(_light.transform.position, _targetPos, posSpeed * Time.deltaTime);
    }