I am trying to simulate the shotgun shot (8 pellets). I spawn all 8 pellets at one point (or very close to each other) and pellets start to interact with each other during shot. This makes the proper shooting and pellets spread mechanics impossible, because pellets affect each other too much.
While I am working on alternative approaches: like make pellets smaller or spawn them far enough from each other or spawning them with some time delay), I am wondering if it’s possible to make physicsImpostor not sensitive to collisions with other physicsImpostor. In other words, is there some collision exclusion list or something like that available under the physicsImpostor/cannon mechanics?
As a last measure I can write my own kinematics, particularly I can progress each pellet on every game tick constantly adding pellet velocity and gravity vector. Then I can do something like this to each pellet:
const EXCLUDED_COLLISION_OBJECTS = ["pellet0", "pellet1", "pellet2", "pellet3", "pellet4", "pellet5", "pellet6", "pellet7", "other"];
function meshIntersectsAnyOnScene (mesh, colliders) {
for (let k = colliders.length - 1; k >= 0; k--) {
if (colliders[k] != mesh
&& constants.EXCLUDED_COLLISION_OBJECTS.indexOf(colliders[k].name) === -1
&& colliders[k].intersectsMesh(mesh, false)) {
return true;
}
}
return false;
}
But in this case I will lose all the nice mechanics that are already inside of physicsImpostor/cannon. For example, ricochets and ballistic shock when pellet hits any other physicsImpostor. So I would really like to keep the physicsImpostor/cannon while making a shot.
I will be even more specific: can I cancel physics computation if some physicsImpostor touched some other specific physicsImpostor without affecting all other collisions?
Reference playground: https://playground.babylonjs.com/#U7AJPW#2. Shot is made automatically after 3 seconds delay. The function handleHit
prints each physicsImpostor
collison to console. I would like to suppress physics computation on each ‘pellet => pellet’ collision.