animations not playing when model is added to render_2d

loading a (model + animation) and setting it’s parent to be other than _render causes animations not to play. for example if the parent is render_2d the animations will not play.

this works fine:

// Load panda
NodePath pandaActor = window->load_model(window->get_render(), "/c/Panda3D-1.7.2/models/panda.egg");
pandaActor.set_pos(init_pos.get_x(), init_pos.get_y(), init_pos.get_z());
// Load the walk animation
window->load_model(pandaActor, "/c/Panda3D-1.7.2/models/panda-walk");
window->loop_animations(0);

this doesn’t work:

// Load panda
NodePath pandaActor = window->load_model(window->get_render_2d(), "/c/Panda3D-1.7.2/models/panda.egg");
pandaActor.set_pos(init_pos.get_x(), init_pos.get_y(), init_pos.get_z());
// Load the walk animation
window->load_model(pandaActor, "/c/Panda3D-1.7.2/models/panda-walk");
window->loop_animations(0);

i found that the reason is the following call:

window->loop_animations(0);

it calls:

auto_bind(get_render().node(), _anim_controls, hierarchy_match_flags);

and so only nodes under the _render nodepath will have their animations bound. probably the method: loop_animations() should be overloaded to accept any node path.

any other solutions?

A fine idea. However, loop_animations() is just intended to be a simple convenience method. All it does is make two function calls, after all, which you can just as easily call directly, in your slightly unusual case.

David

Thank you for your reply David.