Changing Frames per Second

I want to change the number of frames per second that Panda tries to render because, since tasks are called once per frame, a slower computer would have timing issues. I searched for a variable that does what I want in Panda3d’s configuration file but my search was unsuccessful. The “default” value seems to be 60. Any help would be appreciated.

man this would be a great toy^^ lock the framerate^^ :smiley:. no seriously. this only works if the machine can render more frames then you want.
what you are looking for is something else.
if you start a task, a timer is started,too. just do
task.time
to get this time. if you want to know how much time elapsed since the last frame just save this time in a variable … for example

self.lastTaskTime = task.time

and substract this from the task.time when the task is running the next time.

just like this:

def moveForward( self, task ):
    diff = (task.time - self.oldMoveForwardTaskTime) * self.MoveSpeed
    # movement vector
    movement = Vec3( 0, diff, 0)
    # set player position
    self.player.setPos( self.player, movement )
    # save current time
    self.oldMoveForwardTaskTime = task.time
    return Task.cont

befor you start such a task you have to set your oldTimeVariable to 0 and then start the task… just like this

self.oldMoveForwardTaskTime = 0.0
taskMgr.add(self.moveForward, "moveForward")

once you know how much time passed since the last frame you can easily calculate whatever you need in a framerate independend way

This feature should be requested for the new Panda3d version…
BTW is Panda “dead” or is it still developed? I suppose not. However, it has been a LONG time since the last patch…

panda is not dead^^ far away from it.
well there are several features to limit the maximal frame per second count.
but like i already said. its not a good idea to depend on the framerate at all.
in case you need a task that executes itself every 0,2 seconds just do

def yourtask(task):
    #add whatever you want here..  

    taskMgr.doMethodLater( 0.2 , yourtask, 'yourtask' )
    return Task.done

if you really want to go the way over framerates (once more i advise you NOT to do so) this might help you: http://panda3d.org/apiref.php?page=ClockObject#setMode

the reason why limiting the framerate usualy is not used is cause on slow machines the framerate can still drop below the limit.

maybe you can explain why a slow computer would run into a timing issue in your case. cause usualy there are simple solutions for that. without messing around with the framerates and such.
that’s why you’r always better off with running your tasks at the specified time you want.

I saw this thread linked from another and thought I’d make a similar post here just in case anyone with a similar problem misses that thread.

You could also start a periodic task in this manner:

def myPeriodicFunc(task):
    print '60 seconds have elapsed'
    return task.again

taskMgr.doMethodLater(60, myPeriodicFunc, 'myPeriodicFunc')

It’s a little cleaner since this keeps just a single task running without spawning a new one at the completion of the previous one.

As for Panda being dead or not, it’s most certainly not dead. One point of confusion may be the difference between the actively developed code and the binary releases from CMU. Improvements and updates go into the Panda source on a daily basis. However, the pre-built binaries are only updated when the good people over at CMU feel it’s necessary and prudent to push a new “numbered” release.

You could actually build it all from the source yourself, like the CMU distribution team does, if you wanted to get the very latest developments, but that’s a bit of a chore at the moment for newcomers to the project and most people do well enough with the binary releases.