![]() |
Attention | Topic was automatically imported from the old Question2Answer platform. |
![]() |
Asked By | Jay2645 |
I’m trying to get the hang of using C++ modules. I want to create a custom engine module which handles character behavior/movement, so I can easily drag-and-drop a “character” node into a scene and have everything “just work” with minor tweaks. Essentially, my goal is to get this particular step of the FPS tutorial working in a C++ module.
The issue is that the engine’s outliner doesn’t match the nodes I’ve set up in the C++ constructor:
Character::Character() {
_body_collision = memnew(CollisionShape);
_body_collision->set_name("Body_Collision");
_body_collision->set_shape(body_shape);
add_child(_body_collision);
_feet_collision = memnew(CollisionShape);
_feet_collision->set_name("Feet_Collision");
add_child(_feet_collision);
_rotation_helper = memnew(Spatial);
_rotation_helper->set_name("Rotation_Helper");
add_child(_rotation_helper);
_model_base = memnew(Spatial);
_model_base->set_name("Model");
_rotation_helper->add_child(_model_base);
_character_camera = memnew(Camera);
_character_camera->set_name("Camera");
_rotation_helper->add_child(_character_camera);
print_tree_pretty();
}
As you can see, the scene just has the “Character” node, with nothing accessible outside of the body_shape
property I exposed to see if I could get things working. In the console output, though, you can see the actual chain of how nodes are set up internally. If you wanted to add a child node to _rotation_helper
you couldn’t do it very easily without going into scripts.
Is there any way to get this chain to appear in the editor somehow? Or am I approaching this entire thing the wrong way?