Quantcast
Channel: Babylon.js
Viewing all articles
Browse latest Browse all 388

Apply bone orientation and position to mesh without attaching

$
0
0

Hi!

 

In my scene I have multiple instanced robots with single skeleton. When two of them get near enough each they should start shooting lasers.

 

Skeleton has a bone named "Arm.Gun L", its position and orientation already define the origin from where the laser is shot and its direction vector, the problem is that I can't find a way how to access the data. It need to be accessed and copied only once.

 

Find the bone:

this._bone = skeletons[0].bones.filter((b: BABYLON.Bone) => {
	return b.name === "Arm.Gun L";
})[0];

And when firing:

var l = this._laser.createInstance("l");
l.position = ? // this._bone.?
l.rotation = ? // this._bone.?

After looking through the docs for Bone and InstancedMesh (together with its base classes Mesh and Node) the only useful thing I found are local and globalMatrix methods on bones (if I could apply localMatrix to laser would probably do what I want with some minor fixes), but haven't found any efficient way of applying to a laser.


Viewing all articles
Browse latest Browse all 388

Trending Articles