hi,
By this example, i’m searching a way to make simple collision detection between my enemies (red cubes) when they attacks together the yellow cube. I wish the enemies couldn’t get into each other.
I’m searching to do this without decreasing the FPS of my prototype. If i do a test distance between each enemy and the group of enemies and stop the tween of theses enemies, it would be good. The problem, i don’t success to do that.
Could you help me ?
i find bymyself the solution, mobile ok :
//obj 1 :enemy
//obj2 : group
function detect_if_collide_with_group(obj1, obj2, dist) {
if (obj1 != obj2) {
if ((obj1.mesh.position).distanceTo(obj2.mesh.position) < dist) {
// console.log('obj1.mesh : ', obj1.mesh);
if (obj1.is_collide == false) {
obj1.is_collide = true
obj1.tw_attack && obj1.tw_attack.stop()
obj1.tw_warning && obj1.tw_warning.stop()
obj1.tw_move && obj1.tw_move.stop()
obj1.is_warning = true
obj1.is_attack = true
obj1.is_move = true
obj1.echap()
}
// obj1.is_move = false
}
}
}
}
o.enemy.forEach((i) => {
o.enemy_group.forEach((ai) => {
detect_if_collide_with_group(i, ai, params.distance_collision_with_other_enemy)
})
o.obstacle_group.forEach((ai) => {
detect_if_collide_with_group(i, ai, params.distance_collision_with_obstacle)
})
})