[SOLVED] JavaScript detect collisions with a group of objects

Hi,
I have a group of items and I would like to test the collision of any of these objects against the player.
In other words, I would like to implement the javascript equivalent to the conditionitem_groups in collision with player.
I have tried something like the following:



const player = runtimeScene.getObjects("player")[0];
var in_collision_with_evil_object = false;

for (const obj in objects){
    
    in_collision_with_evil_object = player.queryForCollisionWith(obj);  //this does not compile
    if (in_collision_with_evil_object)
        break;
}

Unfortunately, player does not implement queryForCollisionWith.
How can I code this behavior in JavaScript?

Thanks.
-D

I figured it out.
This works:


for (let obj of objects){
 
 in_collision_with_evil_object = gdjs.RuntimeObject.collisionTest(player, obj, false);
    
}
1 Like