CMetaInterval::clear_intervals() causing strange problems...

I’m trying to make an 3D object move automatically every time I press the arrow buttons on my keyboard.

Obviously, the panda should move left when I press the left arrow button, and move right when I press the one with right arrow. I decided to use the intervals: when pressing the left arrow button, I will add one CLerpNodePathInterval object to the interval list; when it is finished, clear the list, and waiting for another key to be pressed.

But strangely, after calling clear_intervals(), every operation related to the interval list will cause segmentation fault. :imp:
Why? And what should I do? Do you have any better way to make the object move?

Sorry for my poor English… :blush: Hope it didn’t make you confused.

clear_intervals() is not meant to be called on a running interval. It’s just part of the interface for constructing the MetaInterval in the first place.

In general, MetaIntervals aren’t meant to be dynamically edited: you set them up, and then run them, and they do what they’re supposed to do and then stop. If you want to change what they’re doing, you have to pause or finish them first.

But to answer your last question, yes: a better way is with tasks instead of intervals. Tasks are designed for the kind of interactive updating that you’re trying to do.

David