Discuss Scratch

Zepist
Scratcher
79 posts

Sprite Collisions

So I need sprites in my game to bounce of eachother. I am making a top down curling, but I don't know how to make accurate collisions, please help https://scratch.mit.edu/projects/1441915255/
absolutegibberish
Scratcher
27 posts

Sprite Collisions

Instead of using touching color blocks, you should make another sprite for collision and use touching sprite blocks instead.
Zepist
Scratcher
79 posts

Sprite Collisions

absolutegibberish wrote:

Instead of using touching color blocks, you should make another sprite for collision and use touching sprite blocks instead.

Even if I did that, I still don't know how to calculate the angles. I reckon the touching colour block would work just as well.
Koamodo975
Scratcher
1000+ posts

Sprite Collisions

Zepist wrote:

absolutegibberish wrote:

Instead of using touching color blocks, you should make another sprite for collision and use touching sprite blocks instead.

Even if I did that, I still don't know how to calculate the angles. I reckon the touching colour block would work just as well.
i gotchu cousin i'm a s-tier idiot coder, check this:
so make an extra costume in the stone sprite that's just a tiny dot, position it at the edge of the stone costume in the editor, and make two variables(imma call em wall start and wall end)
when you hit summat switch to the dot costume. if you're not touching the wall anymore rotate until you are, if you are rotate until you're not, and then set ‘wall start’ to your current angle; now if you WEREN'T touching the wall before rotate in the SAME direction until you're not touching the wall, if you WERE touching the wall, rotate in the OPPOSITE direction until you're not touching; then set ‘wall end’ to your current angle, then get the mean of the start and end variables, that's the direction of the wall you just hit.
now for the ricochet calculation…
uhhhhhhhhh
c-crabi-i-idon'tknowhowtodothat~
OKAY so you probably already know this and take this with a grain of salt because i have never done this before but to calculate the ricochet you'd do
((((2) * (wall mean)) - (angle of the stone's velocity)) + (180))
aaand just plug that into a point () degrees block and it should work!
don't sue me if it doesn't please i'm kinda broke
if this don't make sense i can't really do much about it rn lol i was up hunting mice at 1 am today
oh yeah don't use touching color it really kinda sux

Last edited by Koamodo975 (Yesterday 23:47:08)

Zepist
Scratcher
79 posts

Sprite Collisions

Koamodo975 wrote:

Zepist wrote:

absolutegibberish wrote:

Instead of using touching color blocks, you should make another sprite for collision and use touching sprite blocks instead.

Even if I did that, I still don't know how to calculate the angles. I reckon the touching colour block would work just as well.
i gotchu cousin i'm a s-tier idiot coder, check this:
so make an extra costume in the stone sprite that's just a tiny dot, position it at the edge of the stone costume in the editor, and make two variables(imma call em wall start and wall end)
when you hit summat switch to the dot costume. if you're not touching the wall anymore rotate until you are, if you are rotate until you're not, and then set ‘wall start’ to your current angle; now if you WEREN'T touching the wall before rotate in the SAME direction until you're not touching the wall, if you WERE touching the wall, rotate in the OPPOSITE direction until you're not touching; then set ‘wall end’ to your current angle, then get the mean of the start and end variables, that's the direction of the wall you just hit.
now for the ricochet calculation…
uhhhhhhhhh
c-crabi-i-idon'tknowhowtodothat~
OKAY so you probably already know this and take this with a grain of salt because i have never done this before but to calculate the ricochet you'd do
((((2) * (wall mean)) - (angle of the stone's velocity)) + (180))
aaand just plug that into a point () degrees block and it should work!
don't sue me if it doesn't please i'm kinda broke
if this don't make sense i can't really do much about it rn lol i was up hunting mice at 1 am today
oh yeah don't use touching color it really kinda sux


Ok thanks, I'll try it. I'll do it later though, cause I have to read

Powered by DjangoBB