*I haven’t created the playground yet because I have many lines of code to implement correctly in PG, first I want to know if it has happened to anyone.
the model is in .OBJ and i tried with gltf (keeping x pos =0)
the scale of model, main and collider is ok, i used same config collider for other things and works fine…
in update of all bullets :
if( big_enemy != null ){
switch (big_enemy.name) {
case 'jump_gate_red':
break;
case 'jump_gate_green':
break;
case 'big_enemy_cruiser':
// console.log( 44444 );
_distance = utils.distanceInPlane(this.box.position.x,this.box.position.z,big_enemy.mesh.position.x,big_enemy.mesh.position.z);
if( _distance < big_enemy.radio ){
//collider fisico
// let _coll = scenes[this.parent_scene].getMeshByName("crucero_collider");
if( this.mode ){
// if (this.box.intersectsMesh(_coll, PRECISION_INTERSECTS_MESH)) {
if (scenes[this.parent_scene].getMeshByName("crucero_collider").intersectsPoint(this.box.position, PRECISION_INTERSECTS_MESH)) {
// big_enemy.makeHurt(this.damage,Game.ELEMENT_BULLET,this.box.position);
this.runSparks(Game.ELEMENT_SHIP_ENEMY);
this.dead();
}
}
}
break;
}//end of which boss
}//end coll big enemy
I deciphered your “question”/watched the video and got to the conclusion that the bullets are not colliding with the ship correctly when it is loaded from a glb? hm?
really i preffer use obj, (gltf/glb has a problem with X axis), i tried with that because with obj i need create manually the relations, but i created it now
Another approach is to use multiple boundig boxes so instead of one collider mesh you’ll end up with multiple smaller collider meshes. In this case you can use intersectsPoint and loop trough the colliders from the biggest one to the detailed/smallest ones.
Using a full blown mesh just for collisions is an overkill so I would opt for Yuka or write my own collision detection which would create the AABBs (check the Yuka example page once again, select Bounding Volume to AABB to see what am I talking about) from the meshes imported from Blender (you need a tool to place your BBs precisely) and dispose the meshes afterwards.
Maybe there is a plugin for Blender which can generate the BBs for you.
Talking about YUKA you could use a lot of other stuff from the library for your game
You first check against the big red BB. If it misses you continue to the next bullet. If it hits, you test all the children BBs of the parent BB. For example you can have two children BBs. You will hit one of them. Then you check against its children BBs to the detail level as you want. This is blazingly fast.