For the mini challenge, setting a simple ‘return;’ hadn’t crossed my mind. Instead, I decided to create a function to catch values zero and lower, and handle them in a less direct way.
Essentially, I decided to reset any values close to 0 by resetting it to the default value in code (2f); additionally, I decided to make any negative values positive, by setting them to their absolute value.
(In retrospect, I was a little tired when I did this, and have now realized that it could possibly throw off some split-hair oscillations that may require a negative period value. Learning adventures! Woo!)
Code ensues.
private void PeriodNaNCatcher()
{
if (period == Mathf.Epsilon)
{
period = 2f;
}
else if (period < Mathf.Epsilon)
{
period = Mathf.Abs(period);
}
}