Discuss Scratch

deepkamat
Scratcher
10 posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

Hi, I am creating a platformer game and I want to be able to detect a collision with another sprite's specific Costume Name/Number.
In simple words: I have to detect collision of the player sprite with a clone of the Platform sprite with Costume Name as Trampoline or specific costume number. I want to be able to do this without using the "
<touching color [#4ec86a] ?>
block as it brings in lag

Just for note I want a trampoline in this example which is a clone of the platform sprite placed somewhere on the map, then that specific clone to change to another trampoline costume and the rest I can take care of.

I rather the code being a custom block

Please share if you have any ideas.
Nezon
Scratcher
1000+ posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

when I start as a clone
forever
if <<(costume [name v] :: looks) = [coustume]> and <touching [sprite v] ?>> then

end
end

Last edited by Nezon (Oct. 16, 2020 18:07:18)

imfh
Scratcher
1000+ posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

Have you seen @griffpatch's platformer tutorial? https://scratch.mit.edu/projects/67727504/ In it, he uses another sprite for each set of platforms with unique properties (for example, “Platforms” you can jump through from below). It would probably be easier to do the same for trampolines since you can then just say:

if <touching [Trampolines v] ?> then
...
end
deepkamat
Scratcher
10 posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

Nezon wrote:

when I start as a clone
forever
if <<(costume [name v] :: looks) = [coustume]> and <touching [sprite v] ?>> then

end
end
@Nezon
Sorry but I had already tried that out before posting but for some reason it only works at the corner of the sprite. Dont know why
deepkamat
Scratcher
10 posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

imfh wrote:

Have you seen @griffpatch's platformer tutorial? https://scratch.mit.edu/projects/67727504/ In it, he uses another sprite for each set of platforms with unique properties (for example, “Platforms” you can jump through from below). It would probably be easier to do the same for trampolines since you can then just say:

if <touching [Trampolines v] ?> then
...
end
I actually follow Griffpatch's Scrolling platformer tutorial on youtube
So you are saying that Since, I am going to have a lot of unique platforms in the game. I will have to assign all of them to the player sprite to call a particular function

Ok will try that out and Let you know..

Last edited by deepkamat (Oct. 17, 2020 06:59:47)

deepkamat
Scratcher
10 posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

imfh wrote:

Have you seen @griffpatch's platformer tutorial? https://scratch.mit.edu/projects/67727504/ In it, he uses another sprite for each set of platforms with unique properties (for example, “Platforms” you can jump through from below). It would probably be easier to do the same for trampolines since you can then just say:

if <touching [Trampolines v] ?> then
...
end
See I Tried that but same problem, It just doesn't detect touching trampolines. I thought i would be because of the clones but no even when I touch the Trampolines sprite (Not clone) I was not getting anything to happen except on the corners
So any other way or tell me why is it just detecting the corners of the sprite and not the full sprite?
imfh
Scratcher
1000+ posts

How can I detect Collision of a sprite with a specific costume of another sprite's clone?

Could you share your project and link? It should detect touching any part of the sprite, clone or not. Are you changing the size of your sprite a lot? That can cause issues with touch detection.

Powered by DjangoBB