Discuss Scratch

-starlit_puma-
Scratcher
31 posts

How to make code for colliding clones?

Hello!
I'm looking for a code for clones of the same sprite that are touching each other but can also move around (like if they were marbles in a jar). See this game on Poki to know what I'm talking about.
https://poki.com/en/g/cats-drop
Disclaimer! This is an external link, meaning you'll leave Scratch.

If anyone knows some code for this, that would be great. I'm making a similar game to the one above. I will make sure to give credit in the game description : )

Last edited by -starlit_puma- (Today 01:37:27)

NMario84
Scratcher
1000+ posts

How to make code for colliding clones?

Can't you just use the touching sprite block for this?
<touching [ v] ?>
-starlit_puma-
Scratcher
31 posts

How to make code for colliding clones?

I tried that, however, I'm using clones for my project and I can't get it to work, ie..
when I start as a clone
forever
if <(costume [number v]) = (1)> then
if <touching <(costume [number v]) = [1]>> then
etc...
end
end
end
but since it in and of itself is a clone and what it's touching is a clone, this code ⬆ would only work if the clone was touching the sprite itself rather than another clone, if that makes sense.
hi_bobux725
Scratcher
100+ posts

How to make code for colliding clones?

-starlit_puma- wrote:

I tried that, however, I'm using clones for my project and I can't get it to work, ie..
when I start as a clone
forever
if <(costume [number v]) = (1)> then
if <touching <(costume [number v]) = [1]>> then
etc...
end
end
end
but since it in and of itself is a clone and what it's touching is a clone, this code ⬆ would only work if the clone was touching the sprite itself rather than another clone, if that makes sense.
if a boolean is true, the value is 1 so if the costume number is 1 then the if statement will be
if <touching (1 v)> then
end
hope this helped
-starlit_puma-
Scratcher
31 posts

How to make code for colliding clones?

if <touching ( 1 v)> then

end
thank you! I'll try it

Last edited by -starlit_puma- (Today 03:59:51)

Powered by DjangoBB