Sprite Overlap Prevention

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

I am using this block for all the sprites.

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?

2 Likes

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

Do you want the link to my Thunkable project?

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

I think you can do something like this:

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:

3 Likes

@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

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

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

How do I do this?

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.

1 Like

Thank you so much!!!

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

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.

1 Like