Adding model object at specific position

this is my model code
[java]
cubeModel = assetManager.loadModel(“Models/cube/cube.j3o”);
physicsCharacter = new RigidBodyControl(new BoxCollisionShape(cubeModel.getLocalScale()), .1f);
physicsCharacter.setPhysicsLocation(new Vector3f(-10,-10,-10));
characterNode = new Node(“character node”);
characterNode.addControl(physicsCharacter);
getPhysicsSpace().add(physicsCharacter);
rootNode.attachChild(characterNode);
characterNode.attachChild(cubeModel);
[/java]
well what happens is that the cube spawns in the middle somewhere and starts spinning until it lands. set physics location doesnt change the position of the object

When you add the control to the spatial it takes on the position (and rotation) of the spatial.

well that is where im adding the spatial. How do you add a specific location/rotation to the spatial then?
or is it just to translate the position? assuming that all objects get added to 0,0,0 then

You can either use setLocalTranslation on the spatial or set the physics location later.

1 Like

ah okay this worked, just putting the physicslocation after node had been added . thanks
[java]
cubeModel = assetManager.loadModel(“Models/cube/cube.j3o”);
physicsCharacter = new RigidBodyControl(new BoxCollisionShape(cubeModel.getLocalScale()), .1f);
characterNode = new Node(“character node”);
characterNode.addControl(physicsCharacter);
getPhysicsSpace().add(physicsCharacter);
rootNode.attachChild(characterNode);
characterNode.attachChild(cubeModel);
physicsCharacter.setPhysicsLocation(new Vector3f(0,1,0));
[/java]