BJMonkey’s solution is very elegant, I think, plus his creation of a “blend” parameter, even if it wasn’t needed here, is very interesting to learn.
I was trying now to get back to basics and see what’s going on with these “nan” outputs in the console. I am getting some very strange results.
if I do something like this:
double roundedTime = round(time);
console ("time=",time);
console ("rounded time=”,roundedTime);
What I get as results are things like:
DoGenerate_: new frame
XP: time=8.8666666667
XP: time=8.8666666667
XP: rounded time=0
XP: rounded time=0
No “nan” results, but no correct ones either: roundedTime ought to be 9 instead of 0, oughtn’t it? (and what’s this doubled output per Console entry in the Console window, anyway?)
Now, it seems I sistematically get a “nan” result if I do something like this, say:
double roundedTime = round(time*2);
That is, putting a whole calculation as a function parameter, even if it is something as simple as “time*2” (it will give me a 0 instead when time equals an integer value, though)
But then BJMonkey’s “var = clamp (0,1,Blend*sin(frame*(20/3)));” works without problems, so what gives? Is it a data type thing, “frames” providing integer values and “time” float ones?
(And, by the way, would it be smarter (even if “dirtier") to implicitly do roundings to normalized values variables by declaring them as booleans? Somebody must be having a stroke while reading this
)