Discuss Scratch

-theGameMaker
Scratcher
13 posts

Collision Detecting

So I'm working on a project (Currently shared so you can see https://scratch.mit.edu/projects/975069061/ ), and collision detecting for certain colors isn't working. My code seems fine, but I'm not quite sure. It is in a custom block that has “Run without screen refresh” on, if that changes anything. This is the code:
iftouchingMapHitboxes?thenbroadcastshowHitboxesifnottouchingcolor?thenrepeatuntilnottouchingMapHitboxes?changexbydx*-1changeybydx*-1broadcasthideHitboxes

What I'm trying to do is detect for not touching red. Running it step by step works fine, but all at once gives a different result. The show and hide hitbox broadcasts are showing the map outlines so Scratch can see the colors. The only thing I can think of is that it's sensing for red before it has the hitbox shown, but I can't prove that true or false. If someone could help me out, thanks!
sashimiricedev
Scratcher
100+ posts

Collision Detecting

https://scratch.mit.edu/projects/927729774/ This should help with your problem.
-theGameMaker
Scratcher
13 posts

Collision Detecting

sashimiricedev wrote:

https://scratch.mit.edu/projects/927729774/ This should help with your problem.
So this doesn't exactly help me because it doesn't use color detection. Thanks for trying though.
sashimiricedev
Scratcher
100+ posts

Collision Detecting

In the “Step Collision” block, find the
touchingWall?
blocks and replace them with
touchingcolor?
blocks. It should work as intended.
-theGameMaker
Scratcher
13 posts

Collision Detecting

sashimiricedev wrote:

In the “Step Collision” block, find the
touchingWall?
blocks and replace them with
touchingcolor?
blocks. It should work as intended.
I have tried that, but I think I have I identified the problem. I think that the map isn't showing fast enough, but I don't know anyway to fix it. Thanks again for the help though!

Powered by DjangoBB