# Mutiple guards and other thingy detection sytem

**URL:** <https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105>\
**Category:** Help\
**Tags:** game\
**Created:** [October 29, 2025, 11:24pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105 "2025-10-29T23:24:57Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sickly-Fish](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sickly-fish/32/24873_2.png) [@Sickly-Fish](https://forum.makecode.com/u/Sickly-Fish)\
**Post date:** [October 29, 2025, 11:24pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/1 "2025-10-29T23:24:57Z")

</div>

im making a stealth game and i was trying to make it so that when you step into a range (hitbox) of the guard it slowly raises detection but the levels need multiple guards and i dont know how to do that many detections without having a bunch of variable is there any way i can use a array or smth

---

<div class="post-metadata">

**Author:** ![headcrab\_games](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@headcrab\_games](https://forum.makecode.com/u/headcrab_games)\
**Post date:** [October 30, 2025, 5:52pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/2 "2025-10-30T17:52:02Z")

</div>

could you maybe share the code? I could possibly try and help you if you do

---

<div class="post-metadata">

**Author:** ![redSprite](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/redsprite/32/34262_2.png) [@redSprite](https://forum.makecode.com/u/redSprite)\
**Post date:** [October 30, 2025, 10:32pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/3 "2025-10-30T22:32:51Z")

</div>

So your asking that the more guards that see you at the same time, the more detection will increase?

---

<div class="post-metadata">

**Author:** ![BotWarrior](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/botwarrior/32/25328_2.png) [@BotWarrior](https://forum.makecode.com/u/BotWarrior)\
**Post date:** [October 30, 2025, 10:32pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/4 "2025-10-30T22:32:53Z")

</div>

You could use sprite data, have a number attached to each sprite for detection

---

<div class="post-metadata">

**Author:** ![moopmakers](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/moopmakers/32/31257_2.png) [@moopmakers](https://forum.makecode.com/u/moopmakers)\
**Post date:** [October 30, 2025, 10:33pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/5 "2025-10-30T22:33:47Z")

</div>

I made a guard engine Prototype, and I’m working on getting multiple at once to work

This is what I’ve got for now: [The Prototype](https://arcade.makecode.com/S55350-52244-91100-05485)

---

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [October 30, 2025, 10:33pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/6 "2025-10-30T22:33:49Z")

</div>

You can use the “for element (value) of (list)” block with (list) replaced with “all sprites of kind \<guard type\>” to loop through every guard. then move all your current guard code inside that loop and replace the guard variable with (value)

---

<div class="post-metadata">

**Author:** ![Stickman4269](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/stickman4269/32/23582_2.png) [@Stickman4269](https://forum.makecode.com/u/Stickman4269)\
**Post date:** [October 30, 2025, 10:34pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/7 "2025-10-30T22:34:46Z")

</div>

I would also recommend using [the vision extension](https://github.com/felixtsu/pxt-sight) to stop the guards from seeing through walls (and add a visible vision range if you want to)

---

<div class="post-metadata">

**Author:** ![Sickly-Fish](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sickly-fish/32/24873_2.png) [@Sickly-Fish](https://forum.makecode.com/u/Sickly-Fish)\
**Post date:** [October 30, 2025, 10:34pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/8 "2025-10-30T22:34:49Z")

</div>

thats the thing i dont have the code im trying to figure out how to do it if i need to explain more i can

---

<div class="post-metadata">

**Author:** ![Sickly-Fish](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sickly-fish/32/24873_2.png) [@Sickly-Fish](https://forum.makecode.com/u/Sickly-Fish)\
**Post date:** [October 31, 2025, 5:03pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/9 "2025-10-31T17:03:34Z")

</div>

sprite data does use variables im trying to not have undreds of varis

---

<div class="post-metadata">

**Author:** ![WoofWoof](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/woofwoof/32/32523_2.png) [@WoofWoof](https://forum.makecode.com/u/WoofWoof)\
**Post date:** [October 31, 2025, 5:27pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/10 "2025-10-31T17:27:13Z")

</div>

It sounds like what you really want is a way to determine how many detection ranges the player is inside of. If all the detection ranges are the same size/shape, this is really easy, as you can just check every guard to see if the player is close enough to be in the detection range. The problem happens if your detection ranges are different sizes or shapes. Is this the case?

Maybe sharing the project you have so far will make it easier to understand what you are trying to do.

---

<div class="post-metadata">

**Author:** ![BotWarrior](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/botwarrior/32/25328_2.png) [@BotWarrior](https://forum.makecode.com/u/BotWarrior)\
**Post date:** [October 31, 2025, 10:22pm UTC](https://forum.makecode.com/t/mutiple-guards-and-other-thingy-detection-sytem/40105/11 "2025-10-31T22:22:56Z")

</div>

It uses 1 variable, that each sprite has individually.
