Adding weapon to character hand

I want to add a gun to my character’s right hand, however, I don’t see that gun anywhere near the character. I tried adding the gun group as a child to the hand, and then setting the parent of the gun to that hand. It didn’t work. How do you add a weapon to my character’s hand? If it helps, my character is a mixamo character.

fbxLoader.load("soldier.fbx", function (fbx) {
  fbx.scale.setScalar(0.01);
  let playerBox = new THREE.Box3().setFromObject(fbx);
  scene.add(fbx);
  const playerSize = new THREE.Vector3();
  playerBox.getSize(playerSize);
  const playerGeometry = new THREE.BoxGeometry(playerSize.x, playerSize.y, playerSize.z);
  const playerMesh = new THREE.Mesh(playerGeometry);

  fbxLoader.load("pistol.fbx", async function (fbxPistol) {
    fbxPistol.scale.setScalar(0.01);
    const rightHand = fbx.getObjectByName("mixamorigRightHand");
    rightHand.children.push(fbxPistol); 
    fbxPistol.parent = rightHand;
    console.log(fbx);
  }
}

When you add a 3D model as a child to a bone, all transformations of the bone are also applied to the model. So you might have to update the model’s scaling, position and/or rotation so it appears with the correct transformation.

BTW: Don’t do this:

There is a dedicated method for this use case: rightHand.add( fbxPistol );

1 Like

I tried your solution, and then attempted moving the model. After playing around with some code to get fbxPistol in a better position using fbxPosition.position=… I realised this doesn’t seem to change the position at all. Any ideas how I can apply transformations to my model that actually affect it?