My Solution

After a little bit of thinking about how floats work (this is not my first time needing to compare a float against another float, I did end up using the Mathf.Epsilon.
Though my first thought was to do this:

    void Update()
    {
        while (period != 0)
        {
            OsicllateBlock();
        }
    }

    private void OsicllateBlock()
    {

        float cyclesThrough = Time.time * period;
        const float tau = 2f * Mathf.PI; // about 6.28
        float rawSinWave = Mathf.Sin(cyclesThrough * tau);
        movementFactor = (rawSinWave / 2f) + 0.5f;


        Vector3 displacement = movementVector * movementFactor;
        transform.position = displacement + startingPosition;
    }

Privacy & Terms