Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » Collision is weird
- 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?
“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
Maybe. 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?
I still wonder why collision is undeterministic. (even if you ignore the existance of image pixelation due to screen size)
Why is this?
- undeterministic
- Scratcher
500+ posts
Collision is weird
Here are the revelant source code: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js
- ninjaMAR
- Scratcher
1000+ posts
Collision is weird
(#4)It is line 171. However, it is just delegates util.target.isTouchingObject. I believe util is the sprite the script is running on.
Here are the revelant source code: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js
username checks out
Last edited by ninjaMAR (May 9, 2024 02:30:45)
- undeterministic
- Scratcher
500+ posts
Collision is weird
https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js#L743(#4)It is line 171. However, it is just delegates util.target.isTouchingObject. I believe util is the sprite the script is running on.
Here are the revelant source code: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/blocks/scratch3_sensing.js
username checks out
- 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
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
(#7)RenderedTarget: https://github.com/scratchfoundation/scratch-vm/blob/develop/src/sprites/rendered-target.js
I noticed rendered target extends the class target, which extends EventEmitter, but i can't find it.
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
RIP assets image hosting. 2013?-2023
- Discussion Forums
- » Advanced Topics
- » Collision is weird