Controls in Panda3D


Hello, I am writing a game in C++ and so far I have the scene all done and the actor completed. One thing I’m having issues with, is the controls. I’m aware of how to setup the keys but how would I in C++ get the player to move upon pressing that key.


What you want to do is create a task where you query whether the button in question is pressed or not. If so, you use the relative variant of set_pos or set_y to move your model forwards. You will need to multiply whatever value you pass into it by ClockObject::get_global_clock()->get_dt() in order to properly account for the frame rate.

Also see the Roaming Ralph sample program. It’s Python, but the general idea is the same in C++.