# Hiding Mechanic

**URL:** https://forum.makecode.com/t/hiding-mechanic/21523
**Category:** Arcade
**Tags:** game
**Created:** [July 28, 2023, 4:30pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523 "2023-07-28T16:30:50Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Legboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/legboy/32/9540_2.png) [@Legboy](https://forum.makecode.com/u/Legboy)
#### Post date: [July 28, 2023, 4:30pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/1 "2023-07-28T16:30:50Z")

</div>

So I was trying to build a hiding mechanic into one of my projects that if you would overlap or press a button to enter in a hiding place (like a bush, closet, …) that the enemy would stop following you and start moving in random directions until you leave the place.

Could anyone help?

> **[Hiding Test](https://arcade.makecode.com/S29160-05285-44337-85200)**
>
> Erstellt mit ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [August 21, 2023, 5:04pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/2 "2023-08-21T17:04:12Z")

</div>

Sorry for replying super late, I haven’t seen this post before. I’ve put together a simple example here. You can hide by holding the A button, and stop hiding by releasing it. I’ve made the monster stop chasing you when you hide, but it’s up to you to make it roam around, since I didn’t have much time to implement that. Hope this helps!

> **[Hiding Test](https://arcade.makecode.com/S85708-67017-25012-50662)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/luke/32/32519_2.png) [@Luke](https://forum.makecode.com/u/Luke)
#### Post date: [August 22, 2023, 4:23pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/3 "2023-08-22T16:23:38Z")

</div>

Use @UnsignedArduino’s wandering code:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/2X/d/d466b882c9f62f71f38e3fd04016d77833bc2289.png)

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [August 22, 2023, 4:32pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/4 "2023-08-22T16:32:35Z")

</div>

Didn’t know that existed, but thanks! Besides, this code isn’t for me, but for OP (who seems to have ceased activity)

---

<div class="post-metadata">

### Author: ![Legboy](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/legboy/32/9540_2.png) [@Legboy](https://forum.makecode.com/u/Legboy)
#### Post date: [September 6, 2023, 6:34pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/5 "2023-09-06T18:34:13Z")

</div>

Thank you both for having the time to help me

---

<div class="post-metadata">

### Author: ![Sarge](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/sarge/32/19590_2.png) [@Sarge](https://forum.makecode.com/u/Sarge)
#### Post date: [September 6, 2023, 8:00pm UTC](https://forum.makecode.com/t/hiding-mechanic/21523/6 "2023-09-06T20:00:13Z")

</div>

No problem, that’s why we’re here!
