Need some help with intersectsMesh , getMeshesById

Hi , I want to create a system , if player triggers a special box the global bool will set to true , but I want this functionality for multiple of special boxes

so basically I want to set a bool true/false when it enters some areas (multiple areas )
Right now I am trying something like-
I these areas are checking for “Player’s” intersectMesh and all areas have mesh id “trigger” , " isInTriggerArea" is the boolean

scene.getMeshesById(“trigger”).forEach(element => {

    isInTriggerArea= element.intersectsMesh(Player);



You have told us what you are doing, now what is the question?

Have you tried a simple case in the playground? What happens? What do you want to happen?

the above code is not working

What goes wrong? Please produce a simple playground with a couple of boxes for target areas, a sphere for the player and a test of your logic.

One possibility from what you describe is that you want 'isInTriggerArea` to be true if the player enters any of the target areas, ie if it enters areaA or areaB or areaC etc

in which case you need

scene.getMeshesById(“trigger”).forEach(element => {

    isInTriggerArea |= element.intersectsMesh(Player);


See Bitwise OR assignment (|=) - JavaScript | MDN