ViewDirection and Bone Rotation Problem

Hello Monkeys,

I have run into a problem in a video game I an making. In the game the player is a samurai, to allow the program to detect when the sword hits something I have separated the sword model from the character model, and control the sword with a bone in the character mesh. The problem with this is when I rotate the player with the setViewDirection function, the sword stays still relative to the model even though the bone is moving. Here is a video I made, demonstrating the problem: http://www.youtube.com/watch?v=urV9ag0acaI&feature=youtu.be

Here is my code that controls the swords rot/loc:

physics = the character control
sword = the sword model

[java]
sword.setLocalTranslation(new Vector3f(physics.getPhysicsLocation().x+(control.getSkeleton().getBone(“swordControl.l”).getLocalPosition().x0.03f),physics.getPhysicsLocation().y+(control.getSkeleton().getBone(“swordControl.l”).getLocalPosition().y0.03f), physics.getPhysicsLocation().z+(control.getSkeleton().getBone(“swordControl.l”).getLocalPosition().z*0.03f)));
sword.setLocalRotation(new Quaternion(control.getSkeleton().getBone(“swordControl.l”).getLocalRotation().mult(0.03f).getX(),control.getSkeleton().getBone(“swordControl.l”).getLocalRotation().mult(0.03f).getY(), control.getSkeleton().getBone(“swordControl.l”).getLocalRotation().mult(0.03f).getZ(), control.getSkeleton().getBone(“swordControl.l”).getLocalRotation().mult(0.03f).getW()));

Use attachment nodes - getAttachmentNode from the skeleton, add the sword to that.

Thanks zarch this works!

I marked the topic as resolved for you.