# Need some help with intersectsMesh , getMeshesById

**URL:** <https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308>\
**Category:** Questions\
**Created:** [May 12, 2022, 7:49am UTC](https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308 "2022-05-12T07:49:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![kubo](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@kubo](https://forum.babylonjs.com/u/kubo)\
**Post date:** [May 12, 2022, 7:49am UTC](https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308/1 "2022-05-12T07:49:23Z")

</div>

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);

           

 });
```

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [May 12, 2022, 8:10am UTC](https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308/2 "2022-05-12T08:10:29Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kubo](https://avatars.discourse-cdn.com/v4/letter/k/8edcca/32.png) [@kubo](https://forum.babylonjs.com/u/kubo)\
**Post date:** [May 12, 2022, 8:25am UTC](https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308/3 "2022-05-12T08:25:41Z")

</div>

the above code is not working

---

<div class="post-metadata">

**Author:** ![JohnK](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/johnk/32/26764_2.png) [@JohnK](https://forum.babylonjs.com/u/JohnK)\
**Post date:** [May 12, 2022, 8:36am UTC](https://forum.babylonjs.com/t/need-some-help-with-intersectsmesh-getmeshesbyid/30308/4 "2022-05-12T08:36:11Z")

</div>

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

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

    isInTriggerArea |= element.intersectsMesh(Player);

 });

```

See [Bitwise OR assignment (|=) - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Bitwise_OR_assignment)
