Hi, I think I managed to protect my code against NaN, but Visual Studio keeps showing me this “error” message even with the game working as expected and not showing any error messaged into the console.
In “if (period == 0)” I can see this message in yellow: “fly floating number comparing. Compare a difference with epsilon”
I didn’t understand whet it means…
void Update()
{
if (period == 0)
{
transform.position = startingPos;
}
else
{
Oscillate();
}
}
private void Oscillate()
{
float cycles = Time.time / period;
const float tau = Mathf.PI * 2f;
float rawSinWave = Mathf.Sin(cycles * tau);
movementFactor = rawSinWave / 2f + 0.5f;
Vector3 offset = movementVector * movementFactor;
transform.position = startingPos + offset;
}```