In my cpp file:
Constructor…
LinearEulerIntegrator *lei = new LinearEulerIntegrator();
mPhysicsManager.attach_linear_integrator(lei);
mUpdateEffectsTask = new GenericAsyncTask("mUpdateEffectsTask", (GenericAsyncTask::TaskFunc*)Effects::updateEffectsTask, this);
mTaskMgr = AsyncTaskManager::get_global_ptr();
mTaskMgr->add(mUpdateEffectsTask);
.
.
then in your task (my class is called Effects)
AsyncTask::DoneStatus Effects::updateEffectsTask(GenericAsyncTask* task, void* data) {
I actually forgot to mention it but I do have an AsyncTask including the pm->do_physics(dt), yet it still doesn’t work.
I must have messed up with something along the creation of the force, but in a lack of any example to refer to, I can’t find it. Which is pretty frustrating, actually
looking at your code I see you attached actor node to the model node (test). In the manual they show attaching the model to the actor. Also they show attaching the gravityFN to the top render node, it looks like you attach it to the model node.
I think since your gravityFN is “hanging” under the model node as a child, so that force never gets applied to the model. That’s why they put the forces at the same parent level as the models that need to have the force applied to them.
I know this thread is most of a year old, but for posterity’s sake I think I know what your problem is, having recently gone through a similar situation myself. I don’t think you attached an integrator to your PhysicsManager. To copy a few lines out of of tah’s big reply:
LinearEulerIntegrator *lei = new LinearEulerIntegrator();
mPhysicsManager.attach_linear_integrator(lei);
Physics simply does not work in Panda3d unless your physics manager has an integrator attached to it AND do_physics is called every frame.