Discuss Scratch

BringUpYourPost
Scratcher
500+ posts

Collision is weird

I heard that scratch's collision is not deterministic I thought that was because of screen sizes, I know that is true. but i think there are other causes to this undeterminism. Case in point: GOISE TASING cannot store the exact inputs because the same inputs leads to different state with same screen size.

Last edited by BringUpYourPost (May 9, 2024 19:24:43)

Paddle2See
Scratch Team
1000+ posts

Collision is weird

I have no idea what you are talking about here - but it doesn't seem to be a good fit for “Questions About Scratch”.

“Advanced Topics” maybe?

Scratch Team Member, kayak and pickleball enthusiast, cat caregiver.

This is my forum signature! On a forum post, it is okay for Scratchers to advertise in their forum signature. The signature is the stuff that shows up below the horizontal line on the post. It will show up on every post I make.
(credit to Za-Chary)



;
BringUpYourPost
Scratcher
500+ posts

Collision is weird

Paddle2See wrote:

I have no idea what you are talking about here - but it doesn't seem to be a good fit for “Questions About Scratch”.

“Advanced Topics” maybe?
Maybe.



I still wonder why collision is undeterministic. (even if you ignore the existance of image pixelation due to screen size)

Why is this?
ninjaMAR
Scratcher
1000+ posts

Collision is weird

undeterministic wrote:

(#4)
Here are the revelant source code: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js
It is line 171. However, it is just delegates util.target.isTouchingObject. I believe util is the sprite the script is running on.


username checks out

Last edited by ninjaMAR (May 9, 2024 02:30:45)

undeterministic
Scratcher
500+ posts

Collision is weird

ninjaMAR wrote:

undeterministic wrote:

(#4)
Here are the revelant source code: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js
It is line 171. However, it is just delegates util.target.isTouchingObject. I believe util is the sprite the script is running on.


username checks out
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L743

undeterministic
Scratcher
500+ posts

Collision is weird

I noticed rendered target extends the class target, which extends EventEmitter, but i can't find it.

CST1229
Scratcher
1000+ posts

Collision is weird

util is not the sprite itself, it's an instance of BlockUtility: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/engine/block-utility.js

undeterministic wrote:

(#7)
I noticed rendered target extends the class target, which extends EventEmitter, but i can't find it.
RenderedTarget: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js
Target: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/engine/target.js
EventEmitter is a built-in node.js class, it is not in the scratch-vm code.

The actual touching code is in scratch-render: https://github.com/scratchfoundation/scratch-render/blob/af4b81021842eb792fadde328018c1953022eef3/src/RenderWebGL.js#L961-L1002
It references Drawable.isTouching: https://github.com/scratchfoundation/scratch-render/blob/af4b81021842eb792fadde328018c1953022eef3/src/Drawable.js#L487-L505
Which then eventually references Silhouette.isTouching[Nearest/Linear]: https://github.com/scratchfoundation/scratch-render/blob/af4b81021842eb792fadde328018c1953022eef3/src/Silhouette.js#L219-L242

Silhouette is a class that basically stores the sprite image for collision detection. It gets updated here for vector images: https://github.com/scratchfoundation/scratch-render/blob/af4b81021842eb792fadde328018c1953022eef3/src/SVGSkin.js#L142

Last edited by CST1229 (May 9, 2024 21:02:54)


This is a signature. It's a piece of text that appears below every post I write. Click here to learn more, including how to make your own.
RIP assets image hosting. 2013?-2023



Powered by DjangoBB