Model not following physic shape

I have a scene with a spatial that is a Sphere mesh, i initialize it’s physics that way in an AppState :

   @Override
    public void initialize(AppStateManager stateManager, Application app) {
        super.initialize(stateManager, app);
        
        bulletAppState = new BulletAppState();
        bulletAppState.setDebugEnabled(true);
        stateManager.attach(bulletAppState);
        
         
        rootNode.attachChild(localRootNode);
        
        Spatial scene = assetManager.loadModel("Scenes/level2.j3o");
        
        localRootNode.attachChild(scene);
                
        Spatial floor = localRootNode.getChild("floor");
        bulletAppState.getPhysicsSpace().add(floor.getControl(RigidBodyControl.class));
            
        Spatial Sphere = localRootNode.getChild("Sphere");        
       //bulletAppState.getPhysicsSpace().add(Sphere.getControl(RigidBodyControl.class));   
        bulletAppState.getPhysicsSpace().add(Sphere);

When the main is running the sphere rigidBody is falling, but the mesh does not move and follow.
What is missing ?

I guess the rigidbody control is attached to a child and thus moving that. Attach it to the geometry itself or it’s parent.

I can’t say for sure because I can’t see your hierarchy, but if it is moving a child it won’t move the parent so I can only assume the rigidbody control is too far up the hierarchy.

Sphere.getControl(RigidBodyControl.class).setKinematic(true);

?

i dont see sphere physics so i dont really know how you do it.

you need add proper physics control for sphere

if you want create simple ball physics, then everything is in JME tests and tutorials, just copy paste

This is the hierarchy

I added physics to Sphere with button “add collision shape”

I want sphere RigidBodyControl falling on ground.

How can you tell?

P.S.: imgur.com is a better image hosting site for posting to the forum. a) with a direct URL we can see the whole image without clicking through, b) if we click through we are way less likely to have viruses downloaded to our computer than from the ad-trash on postimg.cc

I see it falling, it has a mass greater than 0.

You see “what” falling? Does the mesh move or not?

2 Likes

could you please create some TestCase code or make a video what happens there exactly?

I will share the scene and source code.

Did you solve the problem?