I think I’m misunderstanding something fundamental to how PosIntervals work. I’m reading the documentation (actually it’s the documentation for LerpPosInterval, but my understanding was that they are the same), and I see a couple bits that seem contradictory to me:
OK, sounds useful. But then the next bit says:
So… It’s been a while since I’ve worked with Python, so maybe that’s what I’m misunderstanding, but… My confusion is that the first quote seems to say that if you pass a function as the startPos parameter, the function won’t get called until the interval actually begins playing. But the second quote seems to give an example of a function being passed as the startPos parameter, and then says that it will be called when the interval is created, not when it begins playing.
Now, looking at an example like
my_interval = nodePath.posInterval(3, this_function(), that_function(), etc)
I would normally expect those functions to get called when my_interval is created, not when the interval starts playing, just as in any other Python code. But given that, I’m not sure what the first quote up above is trying to say. I thought maybe it meant you could pass in a reference to a function like
def a_function(param): return something ref = a_function my_interval = nodePath.posInterval(3, ref, etc...
But when I try that, the function never gets called.
What am I missing here? And how can I create a posInterval that has different, programmatically generated pos and startPos values every time it plays? I can get the effect I’m looking for by creating the interval anew every time I want to play it, but that feels wasteful.