I need convert a global position to local position related to a purple mesh, in this case:
why ?
when bullet impact, i need convert that position to local position related with mesh collider (purple)
because the jumpgate is movement vertically, this is necessary to start/keep a fire/smoke in correct place.
Impact data is obtained from the bullet ray cast.
i tried :
toLocalPosition(_pos,_mesh){
return BABYLON.Vector3.TransformCoordinates(_pos, _mesh.getWorldMatrix().invert());
}
but fails
Bullet crash code
//"this" is a bullet instance
//bigenemy is a jumpgate
const pickResulta = this.ray.intersectsMesh(big_enemy.mesh_collider,false);
if (pickResulta.hit) {
// console.log( this.name, "contra big enemy collider" );
big_enemy.makeHurt(this.damage,pickResulta.pickedPoint,null);
this.runSparksWithCenter(pickResulta.pickedPoint,Game.ELEMENT_JUMP_GATE);
this.dead();
}