How to set the framerate??

Hey, im just wondering is there a way to set the framerate in your program in Panda3d??

I mean besides the v-sync in config.prc

What do you want to set it to?

By default, with video sync off, Panda runs as fast as it can, given the limits of your own code. You can’t “set” the framerate faster than that. But you can set it slower, to limit your framerate to a particular maximum, for instance. Is this what you want?


Yeah i am looking to make it slower

calling taskMgr.step() every certain amount of time might work (???)
instead of:


try using:

    timeBetweenFrames = 1/framesPerSecond
    stepper = Timer(timeBetweenFrames, TaskManager.step, [taskMgr])

keep in mind you can’t speed up you program this way and i don’t know that this works, it’s just a guess

No, that’s not a good way to do it.
Try putting this in Config.prc instead:

clock-mode limited
clock-frame-rate 30

Alternatively, at runtime:


Of course, replace 30 by the desired FPS.


I will do this!

Continuing on this one …

How does one differentiate between visible updates (framerate) and internal updates, i.e. the Hz the game logic runs in? The latter concerns me more right now and I don’t see this commented on anywhere.

My current understanding is that, if you’re using the default run() mainloop, every time the frame refreshes, any active tasks are iterated once. To decouple the two, you may need to write your own logic that keeps updating taskMgr without always updating the graphics, but I don’t know Panda at a low enough level to know if that’s even possible.

You could certainly rewrite the ShowBase.igLoop task to call base.graphicsEngine.renderFrame() only once in a while instead of every time. But there’s a better way now, as of 1.6.x, using the new concept of “task chains”, which unfortunately have yet to be documented well. But the basic idea is that a task chain is a list of tasks, and by default all tasks are on the same task chain “default”. You can put tasks on a specific task chain if you like, and so you can put all of the tasks that you want to run at a special frequency on their own task chain, and set that task chain to run more frequently than “default”.

But this is advanced stuff, and few people actually need to mess with it. It doesn’t help you if all you want is your code to run faster. The short answer there is: Panda runs all of your tasks as fast as they will run. If you want your tasks to run faster, you have to write them so they take less time to run.


How about like updating collision befor updating/importing new things into the game? As of right now, our game, we fall into the void if the fps is to low by trying to load something in the middle of the game.

You can perform a collision traversal whenever you want by calling base.cTrav.traverse(render). You don’t have to wait for ShowBase to do it automatically.

You also might want to consider loading your models in a sub-thread, by using the callback option to loader.loadModel(). This does complicate things, of course. If you want to avoid that complication, you might want to design your game to pause the action and put up a loading screen while you load models.

At the very least, you should design your game to stop the physics while you load models so you don’t keep moving farther than you’re supposed to.


… which is why it’s disadvisable to load during runtime, particularly in the same thread as your main gameplay. Sounds to me like you need to either make your engine framerate-independent, load all content up front, or explore threading and throw some kind of signal when a model is ready to be integrated.

Trying to keep threading down to help lower the error rate, but I may have to set something up like so… Actully I had the same idea just wasnt sure if there wasnt a better way of doing it other then that.

Well actually what I hoped for is some magic little button that you flip and then your game runs at 30 or at 60 Hertz. I guess that is what most developers want.

There is. See my post above.