void Update()
{
// auto set movement factor
if (period == 0){
}
else
{
Oscillate();
}
Vector3 offset = movementVector * movementFactor;
transform.position = startingPos + offset;
}
private void Oscillate()
{
float cycles = Time.time / period; // grows continually from 0
const float tau = Mathf.PI * 2; // about 6.28
float rawSinWave = Mathf.Sin(cycles * tau); // goes from -1 to +1
movementFactor = rawSinWave / 2f + 0.5f;
}
}
I was honestly really surprised it worked and that I got it to work lol