Getting objects in Main App State from Character Controller?

I used the ‘Hello Collision’ tutorial to create physics (Bullet App State) and collision for my world, but there’s a certain thing I cannot figure out how to do. If I added a model to the Scene Explorer and not in the code, how would I add the player Model to the Bullet App State? I figured I could just use an Abstract Control to create my own custom control and then add it to the model, but I have no Idea if it’s even possible to get objects from the main app from a character control. I hope I explained my problem correctly!

Navigate the rootNode until you find your Spatial (player model), then attach your RigidBodyControl (or whatever) to it.

1 Like

You can also use PhysicsSpace.addAll(Node) which traverses the node and adds all PhysicsControls it finds to the physics space. Eventually you’ll probably have to find and somehow map your characters for your other game code somehow anyway though.

If I do this the Player Model will go right through the terrain and then throw a null pointer exception. I am need of figuring out how the scene explorer connects with the actual code, and how I can call models from the scene file itself. I’m sorry for the trouble, I am doing my best to try and learn 3D Game Development, but it is much more oddly organized than 2D.

I’m going to assume that dynamic items should not be put in the scene explorer whatsoever, only static ones. Since I eventually want the character to move and collide with other objects, however I find it much more difficult to manage where the player will be spawned since I cannot envision it myself. Unless there is some way of getting a coordinate from the scene explorer?

Theres many ways to get the spatials in the scene, using the scene graph traversal, rootNode.getChild(name); and others… No problem adding “dynamic” spatials via the SceneComposer. If you want a certain location in the scene, just put a node there and get its location for example.

1 Like

Great! This is just what I needed to make me feel right at home! Thank you very much for devoting your time to answering this question Normen and Pesegato, I appreciate it very much!