Model trying parent a sword

ok so i have a freecamera and a sword i want to attach to the the camera but i use
this code but sword is static in a rock…

        // The weapon mesh

var wp = meshes[0]; // The mesh at index 0 is the parent of the whole object
wp.isVisible = true;
wp.rotationQuaternion = null;
wp.rotation.x = -Math.PI/2;
wp.rotation.y = 1;
wp.parent = this._camera; // The weapon will move with the player camera
wp.position = new BABYLON.Vector3(0.25,-0.4,1);

and im working in angular so little tricky to translate to playground
but bottomline why is not enough to just set mesh parent to camera?
and also how do i rotate the tip to the base of the sword?
like right now its sticked in a rock but if i want cam to “hold” the sword?

You can try setParent() Babylon.js Playground


Simple solution that evaded my attention for some reason. Thanks!

1 Like