I’m trying to attach a gun to a character but can’t find a way to access the character bone. Is there a sample project I can have a look at or a code snippet?
I have already tried the following code:
bone = this.entity.findByName(‘BoneName’);
And:
bone.addChild(gunEntity);
But then I got the following error.
[playcanvas-stable.js:7951]: Error: GraphNode is already parented
I also tried reparenting the weapon but can’t see the weapon in the character’s hand.
this.gun.reparent(this.rightHandBone);
Also check that the weapon isn’t currently translated a massive amount in some direction. A .setLocalPosition(pc.Vec3.ZERO) would ensure that it is right at the bone.