# Bug when hit wall

**URL:** <https://forum.makecode.com/t/bug-when-hit-wall/31923>\
**Category:** Help\
**Created:** [November 24, 2024, 4:50pm UTC](https://forum.makecode.com/t/bug-when-hit-wall/31923 "2024-11-24T16:50:13Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluevr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bluevr/32/18217_2.png) [@bluevr](https://forum.makecode.com/u/bluevr)\
**Post date:** [November 24, 2024, 4:50pm UTC](https://forum.makecode.com/t/bug-when-hit-wall/31923/1 "2024-11-24T16:50:13Z")

</div>

so I’m making a game and there’s a bug where when you hit a wall you faze through it does any one know how to fix it?

> **[wild bobs quest](https://arcade.makecode.com/S38005-00291-44573-43979)**
>
> Made with ❤️ in Microsoft MakeCode Arcade.

---

<div class="post-metadata">

**Author:** ![Don](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/don/32/17989_2.png) [@Don](https://forum.makecode.com/u/Don)\
**Post date:** [November 24, 2024, 7:20pm UTC](https://forum.makecode.com/t/bug-when-hit-wall/31923/2 "2024-11-24T19:20:14Z")

</div>

Going through this there are some things to fix.

First off don’t use a variable named mySprite3 to determine which way you are facing. A better name would be facing. Adding some constants called RIGHT and LEFT will also help you with making your code readable so:

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/6/863cb423f90cf0913924beedb6f86a5ce2083cca.png)

You can still use the **move with buttons** block just set vy to zero. Now you can add a simple up button pressed event to jump, but only if you are standing on firm ground.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/8/38dd507dcc355a00357318082c706e04e9f1e339.png)

I would remove walls from those little blocks in the corners. Marking the whole area as a wall while showing a tiny block is misleading to a player.

You also need to set the facing. An easy way to do that is to look at vx

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/5/e/5eca475cdb32a52e0588ecaf1b6b145146d021d2.png)  
Change the facing to the last direction the sprite was moving in. Notice there is no plain else. If you are standing still you will shoot in the direction you were last moving in.

After these changes Bob doesn’t fall down. So why was he doing that? You are doing a direct addition to the x position instead of using velocity.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/8/a/8a93dc2787c921a9a50fcabf931f18a97437d861.png)  
By doing that Bob can jump over a wall instead of hitting the wall.

---

<div class="post-metadata">

**Author:** ![Brohann](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/brohann/32/17380_2.png) [@Brohann](https://forum.makecode.com/u/Brohann)\
**Post date:** [November 25, 2024, 2:43am UTC](https://forum.makecode.com/t/bug-when-hit-wall/31923/3 "2024-11-25T02:43:12Z")

</div>

> [@Don](#):
>
> Adding some constants called RIGHT and LEFT will also help you with making your code readable so:

It would be even better if you used true and false instead of 0 and 1

 ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/5/5/552d8b5952acb9b0bfcad9d28832304bf54436d6.png)

---

<div class="post-metadata">

**Author:** ![bluevr](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/bluevr/32/18217_2.png) [@bluevr](https://forum.makecode.com/u/bluevr)\
**Post date:** [November 25, 2024, 2:44am UTC](https://forum.makecode.com/t/bug-when-hit-wall/31923/4 "2024-11-25T02:44:43Z")

</div>

thank you
