# Sprite Overlap Prevention

**URL:** <https://community.thunkable.com/t/sprite-overlap-prevention/1289102>\
**Category:** Questions about Thunkable X\
**Created:** [May 17, 2021, 1:59pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102 "2021-05-17T13:59:19Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 17, 2021, 1:59pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/1 "2021-05-17T13:59:19Z")

</div>

How do you prevent sprites from overlapping when they move around the canvas using blocks or designer?

 ![Screenshot 2021-05-17 9.57.27 AM](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/5/b/5b12a7f972ac16a254f837169071d0ddbab30295.png)

I am using this block for all the sprites.

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 17, 2021, 2:08pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/2 "2021-05-17T14:08:55Z")

</div>

If you have your sprites set to NOT ‘passes through’ (in designer), they’ll bounce off each other. Is that what you’re looking for, or something else?

---

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 17, 2021, 2:09pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/3 "2021-05-17T14:09:59Z")

</div>

They don’t pass through each other. They move to a random new location.

Do you want the link to my Thunkable project?

---

<div class="post-metadata">

**Author:** ![catsarisky](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/catsarisky/32/100661_2.png) [@catsarisky](https://community.thunkable.com/u/catsarisky)\
**Post date:** [May 17, 2021, 2:37pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/4 "2021-05-17T14:37:36Z")

</div>

I guess I don’t understand what you’re trying to do?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 17, 2021, 2:48pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/5 "2021-05-17T14:48:14Z")

</div>

I think you can do something like this:

```auto
Repeat while [touching Sprite9]
   move [Sprite9] to x [random integer from 50 to 350] y [random integer from 50 to 350]

```

Or just use this block and put your move block inside it:

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/e/f/ef98dd0b30ef686e82bb236baa6ebfeb932fe3ef.png)

---

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 17, 2021, 4:44pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/6 "2021-05-17T16:44:38Z")

</div>

@catsarisky  
@tatiang

Thanks for your replies. I’ll share my project, and you can give me suggestions on that. Sorry for not responding before.

[https://x.thunkable.com/copy/760af3a0cc45dcd849ef5958138026d0](https://x.thunkable.com/copy/760af3a0cc45dcd849ef5958138026d0)

If you live test, you will find the error that I want fixed.

---

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 17, 2021, 4:54pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/7 "2021-05-17T16:54:37Z")

</div>

I already used the “When \_\_ collides with \_\_” block in my code.

> [@tatiang](#):
>
> `Repeat while [touching Sprite9]`

How do I do this?

---

<div class="post-metadata">

**Author:** ![tatiang](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/tatiang/32/55482_2.png) [@tatiang](https://community.thunkable.com/u/tatiang)\
**Post date:** [May 17, 2021, 6:39pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/8 "2021-05-17T18:39:11Z")

</div>

> [@human](#):
>
> [Thunkable](https://x.thunkable.com/copy/760af3a0cc45dcd849ef5958138026d0)

This is what I was thinking but I’m not sure it will work. I think you would need all sprite images to be in a **single sprite**.

 ![image](https://us1.discourse-cdn.com/flex015/uploads/thunkable/original/3X/7/a/7a5c088b4790234a82fbbeaac97fc4259fede940.png)

---

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 17, 2021, 6:48pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/9 "2021-05-17T18:48:03Z")

</div>

Thank you so much!!!

The “distance between \_\_ and \_\_” block is just what I need. Good idea!

---

<div class="post-metadata">

**Author:** ![human](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/human/32/101416_2.png) [@human](https://community.thunkable.com/u/human)\
**Post date:** [May 21, 2021, 3:21pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/10 "2021-05-21T15:21:38Z")

</div>

Thank you so much @tatiang and @catsarisky for putting in the time to help me.

@tatiang, I liked your solution but it is going to take more time than I need.

So I have a better idea. **I can temporarily move my character sprite outside the range the presents are moving and then move it back again when they are done moving.**

Hope this can be a reference to other people who are facing the same issue.

I will edit this post to include a link to WDC #16, where you can see my updated app and remix it.

---

<div class="post-metadata">

**Author:** ![ioannis](https://sea1.discourse-cdn.com/flex015/user_avatar/community.thunkable.com/ioannis/32/146956_2.png) [@ioannis](https://community.thunkable.com/u/ioannis)\
**Post date:** [November 8, 2024, 1:22pm UTC](https://community.thunkable.com/t/sprite-overlap-prevention/1289102/11 "2024-11-08T13:22:27Z")

</div>


