[SOLVED] setPhysicsLocation has no effect on rigid body

Hello,



I don’t understand why the setPhysicsLocation does not do what i expect

the rigid body is always starting at 0,0,0 in the physic simulation

Code:
CapsuleCollisionShape capsuleShape = new CapsuleCollisionShape(1.0f, 2.0f, 1); playerBody = new CharacterControl(capsuleShape, 0.05f); playerBody.setJumpSpeed(20); playerBody.setFallSpeed(30); playerBody.setGravity(30); bulletAppState.getPhysicsSpace().add(playerBody);
    playerBody.setPhysicsLocation(new Vector3f(20, 20, 20)); //// -------------- DOES NOT WORK

    //----------------------------------------------------------------------

    playerSpatial = (Node) assetManager.loadModel("models/thing.mesh.xml"); 
    playerSpatial.addControl(playerBody);
    rootNode.attachChild(playerSpatial);</div>


anyone can help ?

thx

That code seems to be right, something else is going wrong that I cannot see… You sure this bit of code is executed at all? Maybe try moving before adding the body to the physics space but it should make no difference really…

ok i found it



the trick is to set the transform on the spatial

not on the physic body

me stupid :slight_smile:

Uh, no… That should not work. You really sure you see the same spatial? Is your physics space active at all?

I do not have access to my code so might be remembering wrong but I think it has to do with the order of adding stuff to the root node and/or bullet and setting the physics location.

For me it works if I first add the physics control to bullet, then add the spatial to the root node and last set the physics location. Not sure what of that actually matters. Try to reorder things and see if and what makes a difference :slight_smile:

Ah yeh, you are right, I was ignoring the code below the line… When the control is added to the spatial it takes its transform. This is so to make it easy to move the control to another spatial.

yep stupid error of me :slight_smile: