Issues with my method

Hello,



I’m having issues with a 2d texture shown above a models head. At the moment it dose this:

http://www.youtube.com/watch?v=AoVs5VXisaM



It laggs behind when my model moves, this is the current code im using:

BitmapFont font = _game.getAssetManager().loadFont("Interface/Fonts/Default.fnt");
modelName = new BitmapText(font, false);
modelName.setShadowMode(ShadowMode.Off);
modelName.setText("Ogre Dude");
modelName.setBox(new Rectangle(-0.7f, 0f, 1.6f, 0.16f));
modelName.setAlignment(Align.Center);
modelName.setSize(0.3f);
modelName.addControl(new BillboardControl());
_game.getRootNode().attachChild(modelName);
Vector3f vec = getModel().getLocalTranslation().clone();
vec.y += 5;
modelName.setLocalTranslation(vec);

// And inside a control update() method:
Vector3f vec = getModel().getLocalTranslation();
Vector3f vec2 = modelName.getLocalTranslation();
vec2.set(vec);
vec2.y += 3;
modelName.setLocalTranslation(vec2);


Any advice on a better method of doing this?

Regards,
Seth

try using getWorldTranslation

thanks for the fast reply normen, but its still doing the same thing…

Then you probably move the ogre after you move the text.

I’m using a CharacterControl for the model and setting the walk direction as you did in TestCharacterWalking class. So im guessing the physics control moves the model later… is it so?

Since I don’t know when you call that code I cannot tell you. If its in a Control that you attach to the spatial like it should be then it will be called after the CharacterControl moved it :stuck_out_tongue:

Solved the issue, i was adding the control that was moving the model into root node instead of the model >.>

Now its working just fine, thanks for the help and the lesson!