# Richard’s Arcade Tips #8 - Hitboxes, Overlaps, and Collisions (Part 3)

**URL:** <https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117>\
**Category:** MakeCode Blog\
**Tags:** arcade-tips\
**Created:** [July 29, 2026, 2:08am UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117 "2026-07-29T02:08:05Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 29, 2026, 2:08am UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/1 "2026-07-29T02:08:05Z")

</div>

Hey folks!

It’s time for the exciting conclusion in my series on hitboxes, overlaps, and collisions! Before continuing, you may want to check out [part 1](https://forum.makecode.com/t/richards-arcade-tips-6-hitboxes-overlaps-and-collisions-part-1/45107) and [part 2](https://forum.makecode.com/t/richard-s-arcade-tips-7-hitboxes-overlaps-and-collisions-part-2/45108) where I explain how overlaps and collisions work in the arcade physics engine.

Today, we’re going to be looking at some code examples you can use in your games that let you control the overlaps and collisions of sprites!

# Sprite Flags

First, let’s take a look at a block that doesn’t get as much love as it deserves! The humble sprite flag block:

![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/7/7/770d1432b4623bc490dec184433af7b697454915.png)

This block lets you customize how a sprite behaves by turning features on and off. In particular, I want to highlight a few flags that I’ll be referencing throughout this post:

- `ghost through sprites`
- `ghost through tiles`
- `ghost through walls`
- `ghost`

These flags are used for enabling and disabling all of the different overlap and collision checks that the physics engine performs on sprites each frame. If you don’t know what any of them mean, click on the sections below to learn what they do and which blocks they affect!

> **Ghost through sprites**
>
> When this flag is on, a sprite will not trigger any overlap events. That’s this event here:
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/5/1509cd3d3ae7c5c147e31891c153ca2d64a5dc88.png)
> 
> It also makes it so that the manual overlap check block will always return false, even if the sprites are overlapping:
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/d/e/de96278ab8cd8f41951bf37c0ea7e2940bf57788.png)
> 
> We won’t be mentioning this block much in the examples below, but it’s pretty useful! Try using it to make sprites temporarily invincible or to improve your game performance when you have hundreds of sprites!

> **Ghost through tiles**
>
> When this flag is on, a sprite will not trigger any tile overlap events. That’s this block:
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/1/d/1dc72de4376539669e34375438ddea6c6a6ce269.png)

> **Ghost through walls**
>
> When this flag is on, a sprite will ignore all wall collisions! This flag is super useful for sprites like menus and HUD elements that you don’t actually want to be boxed in by your tilemap.
> 
> These two blocks also won’t do anything for sprites that have this flag enabled:
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/b/1/b1cef98f20406789691ea9bfe38e36406c390726.png)
> 
> ![image](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/3/7/37d474356d7aed69513db790b7b7536f915a5afd.png)

Finally, we have the `ghost` flag! The `ghost` flag is just a nifty way of turning all of these ghost flags on or off at the same time. Very useful for sprites that are just for decoration!

# Example 1: Hitbox Sprites

Very often in arcade, you’re going to want to animate a sprite that moves around and each frame of that animation is not going to have the exact same size. This is true for a lot of animations in the gallery, so let’s take a look at one:

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

Remember, the hitbox of a sprite is drawn around the non-transparent pixels. In the above animation, the hitbox is marked in red and you can see that in frames 1, 2, and 6 the hitbox has different dimensions than the other 3.

If the hitbox is constantly changing, you can get some glitchy effects when colliding with walls in a tilemap. A lot of times this will look like the sprite is “glitching out” as the animation plays, like in the example below:

[![glitching](https://us1.discourse-cdn.com/flex020/uploads/makecode/original/3X/4/c/4c977484a1c6f0f9aac5f9c66f55150aeb6089de.gif)](https://arcade.makecode.com/S83930-72055-31642-97645)

If you look at the sprite on the left, the animation looks glitchy because of the changing hitbox size. The sprite on the right looks much smoother.

To fix this issue, the easiest way is actually to split your sprite in two!

We’re going to create two sprites:

- A **hitbox** sprite - this is the sprite that we will be using for all of our overlaps, physics, and controller code
- An **animation** sprite - this is a sprite that we will only use for playing animations. It’s only for decoration, we’ll use an `on game update` block to move it on top of the hitbox every frame.

The code looks something like this:

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

Note that we have set the `invisible` flag on the hitbox sprite so that the player doesn’t see it. The animation sprite has the `ghost` flag set so that it ignores walls and other events.

The `on game update` block in the above code is used to make sure that the animation sprite is always on top of the hitbox sprite.

Try the code out here:

> **[hitbox-example](https://arcade.makecode.com/S08560-05845-26382-27335)**
>
> An example of using a hitbox sprite! The top sprite is using a hitbox sprite, the bottom one is not. Try holding the up button and moving left and right! The top sprite doesn't glitch out but the bottom one does!

---

<div class="post-metadata">

**Author:** ![richard](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/richard/32/5417_2.png) [@richard](https://forum.makecode.com/u/richard)\
**Post date:** [July 29, 2026, 2:09am UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/2 "2026-07-29T02:09:18Z")

</div>

hey folks! i wanted to get this post out today because i said i would, but i’ll probably be updating it later this week to have more examples.

---

<div class="post-metadata">

**Author:** ![Vital](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vital/32/33353_2.png) [@Vital](https://forum.makecode.com/u/Vital)\
**Post date:** [July 30, 2026, 2:47am UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/3 "2026-07-30T02:47:08Z")

</div>

Hi! Vital here! For a game that I’m making, I have a Hitbox sprite that checks if the player is up against a wall. The sprite is constantly on top of the player, but is 1 pixel wider than the player, so that it checks if you are against the wall or touching it. The problem is that the ‘hitbox’ needs to pass through walls but also detect if it is touching one. Is there any way to do this? Thanks!

---

<div class="post-metadata">

**Author:** ![VoxelMaster64](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/voxelmaster64/32/32075_2.png) [@VoxelMaster64](https://forum.makecode.com/u/VoxelMaster64)\
**Post date:** [July 30, 2026, 4:45pm UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/4 "2026-07-30T16:45:26Z")

</div>

maybe use 2 hitboxes, one for touching and one for being against the wall. Do you mean something like [this](https://arcade.makecode.com/S64355-43478-88545-29845)?

---

<div class="post-metadata">

**Author:** ![Vital](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/vital/32/33353_2.png) [@Vital](https://forum.makecode.com/u/Vital)\
**Post date:** [July 31, 2026, 2:19am UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/5 "2026-07-31T02:19:56Z")

</div>

Oh. My. GOSH! You are a genius and I thank you for saving me!

---

<div class="post-metadata">

**Author:** ![TheEarth](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.makecode.com/theearth/32/34579_2.png) [@TheEarth](https://forum.makecode.com/u/TheEarth)\
**Post date:** [August 12, 2026, 10:41pm UTC](https://forum.makecode.com/t/richard-s-arcade-tips-8-hitboxes-overlaps-and-collisions-part-3/45117/6 "2026-08-12T22:41:59Z")

</div>

Even Richard uses the all mighty pink placeholder sprite
