(Bobbing Issue) What's the Problem with my Code?

Hello guys,

Im using this Code to make Simple Weapon Bobbing.

    void Update()
    {
        if (something)
        {
            return; // pause the calccalculation & pause the position 
        }
        float theta = (Time.timeSinceLevelLoad / period) * 0.1f;
        float distance = amplitude * Mathf.Sin(theta);
        transform.localPosition = startPos + Vector3.up * distance;
    }

Are you sure “something” is never set to true? Are you sure that code elsewhere isn’t causing your game to freeze up? Add Debug.Log statements to track what is happening, and look at what the Profiler shows when these hitches occur.