Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » 3D on scratch, And how it's professionally accomplished
- LucidX1235
-
7 posts
3D on scratch, And how it's professionally accomplished
Stupid question on how you make these, do you have a base engine you can edit to make games, or do you make a slightly different one from scratch every time>
- GL00B
-
83 posts
3D on scratch, And how it's professionally accomplished
No, i make every game from the very scratch. That way, I can change the way it works depending on what i need for the game. take the tekken 4 game and nfs 3 game, why would i need such a complex wall render for a fighting game? same goes for the car game, the car model is super simple and doesn't need a rotating vertex render Stupid question on how you make these, do you have a base engine you can edit to make games, or do you make a slightly different one from scratch every time>
- LucidX1235
-
7 posts
3D on scratch, And how it's professionally accomplished
wow ok that's actually really cool No, i make every game from the very scratch. That way, I can change the way it works depending on what i need for the game. take the tekken 4 game and nfs 3 game, why would i need such a complex wall render for a fighting game? same goes for the car game, the car model is super simple and doesn't need a rotating vertex render
- HKEY_LOCAL_MACHINE
-
15 posts
3D on scratch, And how it's professionally accomplished
im trying to make a 3d engine and right now i can fill the screen with colors but i dont know how to apply it. im using unsandboxed. im trying to render by moving a sprite to the far bottom left and moving right until it hit the edge (then moving up and repeating) but i want to render games similar to your daytona (similar performance) but an fps similar to the COD campaigns, just less fx
- kittygamer8997
-
62 posts
3D on scratch, And how it's professionally accomplished
@GL00B I saw your profile comments were closed so I have to type here but I have something maybe you know about that will improve some stuff. Its the For Each block, it is compatible with scratch and runs loops 10x faster
its in a extension of turbowarp. Your games do a lot of calculations so it will still be laggy but it could possibly run better. Im using it for my 3D space game, possibly the best space simulation on scratch because I havent seen anything better yet. Idk if this format works in scratch blocks

For Each []in ()
End
Last edited by kittygamer8997 (May 25, 2025 15:17:04)
- kittygamer8997
-
62 posts
3D on scratch, And how it's professionally accomplished
Idk how to make the loop @GL00B I saw your profile comments were closed so I have to type here but I have something maybe you know about that will improve some stuff. Its the For Each block, it is compatible with scratch and runs loops 10x fasterits in a extension of turbowarp. Your games do a lot of calculations so it will still be laggy but it could possibly run better. Im using it for my 3D space game, possibly the best space simulation on scratch because I havent seen anything better yet. Idk if this format works in scratch blocks
for each [i] in (100)
end
- kittygamer8997
-
62 posts
3D on scratch, And how it's professionally accomplished
Idk how to make the block look like a repeat loop but its just a different look of a repeat block @GL00B I saw your profile comments were closed so I have to type here but I have something maybe you know about that will improve some stuff. Its the For Each block, it is compatible with scratch and runs loops 10x fasterits in a extension of turbowarp. Your games do a lot of calculations so it will still be laggy but it could possibly run better. Im using it for my 3D space game, possibly the best space simulation on scratch because I havent seen anything better yet. Idk if this format works in scratch blocks
for each [i] in (100)
end
- kittygamer8997
-
62 posts
3D on scratch, And how it's professionally accomplished
@GL00B I saw your profile comments were closed so I have to type here but I have something maybe you know about that will improve some stuff. Its the For Each block, it is compatible with scratch and runs loops 10x fasterits in a extension of turbowarp. Your games do a lot of calculations so it will still be laggy but it could possibly run better. Im using it for my 3D space game, possibly the best space simulation on scratch because I havent seen anything better yet. Idk if this format works in scratch blocks
For Each []in ()
end
- matthewpanop
-
11 posts
3D on scratch, And how it's professionally accomplished
I know I did not ask the original question but is it like a very long sprite that detects if a wall is touching itToo much stuff. i am very very very confused and how would you even make the map?I always wondered how I could do something like line intersection raycasting because I don't know how that works. how does it detect collisions like that? I only know step by step or DDA. how does it know where the collision is??? please teach me or give me something to tell me how it works.
Glad you're interested! Since you know how to code a DDA raycaster, I'm really sure that you use vectors for it. Your Line intersection raycaster will have the same code as your normal DDA raycaster up until the actual loop. there, you will be checking a list that has your map data, cycling through it. you won't be using a voxel list, or a tile list, nope, just a list that has your data in certain packets that you can cycle through by the length of the packet. so simply:
( Wall_index * ( Packet_length ) + Wall_attribute [ this is where you store the x1,y1,z2,texture,height,anything you can think of. ) of
then you will use a line intersection formula, to find the intersection between 2 lines. one will be your ray, and the other will be the wall in the list. you cycle through the list and you will have checked intersection with the rays. the formula i use is this one :
https://www.youtube.com/watch?v=bvlIYX9cgls
You will use the alpha and beta to determine the Distance and the U coordinate in the texture of that wall. Thats all
****note****
you will realise the walls are NOT sorted, so you will need to use a z buffer, which will limit the y axis's resolution too. it will also greatly reduce the performance, so code it right and avoid extra calculations as much as possible!
Okay, lets simplify it. imagine the ray in a normal raycaster as a bullet that keeps moving till it hits something. right?
well, in our line segment raycaster, there is no bullet. there is just a laser beam, that instantly shows!
this laser beam checks if any lines are touching it. forget about making the map now, just tell me, is this clear? you are not moving till you hit a wall, you already hit the wall ever since the “beam” spawned, which is just a really long line that starts at your camera's position and it's end is a point that's equal to your vector + camera position.
- GL00B
-
83 posts
3D on scratch, And how it's professionally accomplished
Nope, it isnt a sprite at all. It's more of a formula, a custom block, that has 8 inputs. 4 for the first line, which will have the first 2 inputs as cam x and cam z, and 2 others which will be the vector multiplied by a really huge number. the other 4 points are your wall. this way, you can detect intersection!I know I did not ask the original question but is it like a very long sprite that detects if a wall is touching itToo much stuff. i am very very very confused and how would you even make the map?I always wondered how I could do something like line intersection raycasting because I don't know how that works. how does it detect collisions like that? I only know step by step or DDA. how does it know where the collision is??? please teach me or give me something to tell me how it works.
Glad you're interested! Since you know how to code a DDA raycaster, I'm really sure that you use vectors for it. Your Line intersection raycaster will have the same code as your normal DDA raycaster up until the actual loop. there, you will be checking a list that has your map data, cycling through it. you won't be using a voxel list, or a tile list, nope, just a list that has your data in certain packets that you can cycle through by the length of the packet. so simply:
( Wall_index * ( Packet_length ) + Wall_attribute [ this is where you store the x1,y1,z2,texture,height,anything you can think of. ) of
then you will use a line intersection formula, to find the intersection between 2 lines. one will be your ray, and the other will be the wall in the list. you cycle through the list and you will have checked intersection with the rays. the formula i use is this one :
https://www.youtube.com/watch?v=bvlIYX9cgls
You will use the alpha and beta to determine the Distance and the U coordinate in the texture of that wall. Thats all
****note****
you will realise the walls are NOT sorted, so you will need to use a z buffer, which will limit the y axis's resolution too. it will also greatly reduce the performance, so code it right and avoid extra calculations as much as possible!
Okay, lets simplify it. imagine the ray in a normal raycaster as a bullet that keeps moving till it hits something. right?
well, in our line segment raycaster, there is no bullet. there is just a laser beam, that instantly shows!
this laser beam checks if any lines are touching it. forget about making the map now, just tell me, is this clear? you are not moving till you hit a wall, you already hit the wall ever since the “beam” spawned, which is just a really long line that starts at your camera's position and it's end is a point that's equal to your vector + camera position.
- N8_D_GR8_1
-
1000+ posts
3D on scratch, And how it's professionally accomplished
I think you mean this: -snip-
for each [ i v] in (10) {
do something with (i)::custom
}::control
It was a block that was removed from scratch a while back, but is still supported. You can use it in a program by using the opcode “control_for_each” or backpacking it from a project that has one. I've only noticed very small changes in performance with this block, but it can come in handy for simplifying code a bit.
https://en.scratch-wiki.info/wiki/For_Each_()_in_()
- 23mConnor
-
50 posts
3D on scratch, And how it's professionally accomplished
I’ve tried 3d elements, but the most I got was a 2d rectangle that created it’s shape sl o w l y.
Still, it’s a cool ambition, I might return to racking my brain around such things before the end of this year!
Still, it’s a cool ambition, I might return to racking my brain around such things before the end of this year!
- HKEY_LOCAL_MACHINE
-
15 posts
3D on scratch, And how it's professionally accomplished
i fugured out how to render super fast with unsandboxed but it can only color the screen from a list I’ve tried 3d elements, but the most I got was a 2d rectangle that created it’s shape sl o w l y.
Still, it’s a cool ambition, I might return to racking my brain around such things before the end of this year!
- LucidX1235
-
7 posts
3D on scratch, And how it's professionally accomplished
https://scratch.mit.edu/projects/1064911854/
Does this use the Raytracing method? And how do the textures “warp”? Or are they individual pixels changing color? I want to know please!
It says in the desc it uses raycasting. To warp I think you can set the size of a pen to change over time when drawing a line.
Last edited by LucidX1235 (June 4, 2025 15:16:39)
- kittygamer8997
-
62 posts
3D on scratch, And how it's professionally accomplished
Yes, its also a extension in turbo.I think you mean this: -snip-for each [ i v] in (10) {
do something with (i)::custom
}::control
It was a block that was removed from scratch a while back, but is still supported. You can use it in a program by using the opcode “control_for_each” or backpacking it from a project that has one. I've only noticed very small changes in performance with this block, but it can come in handy for simplifying code a bit.
https://en.scratch-wiki.info/wiki/For_Each_()_in_()
Last edited by kittygamer8997 (June 5, 2025 23:45:00)
- scratchcode1_2_3
-
1000+ posts
3D on scratch, And how it's professionally accomplished
WHAT YOU GOT STICKIED CONGRATS DUDE!!!!!
- magicsponge321
-
100+ posts
3D on scratch, And how it's professionally accomplished
I'm trying to make a raycaster, like you recommended, but I'm stuck on making FOV and making it.. ya know, 3d.
Here's the link: https://scratch.mit.edu/projects/1189288628
Here's the link: https://scratch.mit.edu/projects/1189288628
- ajspeckhals
-
44 posts
3D on scratch, And how it's professionally accomplished
griffpatch has a yt tutorial on that I'm trying to make a raycaster, like you recommended, but I'm stuck on making FOV and making it.. ya know, 3d.
Here's the link: https://scratch.mit.edu/projects/1189288628
- magicsponge321
-
100+ posts
3D on scratch, And how it's professionally accomplished
I'm trying not to follow yt tutorials because there's already a million of those griffpatch raycastersgriffpatch has a yt tutorial on that I'm trying to make a raycaster, like you recommended, but I'm stuck on making FOV and making it.. ya know, 3d.
Here's the link: https://scratch.mit.edu/projects/1189288628
- magicsponge321
-
100+ posts
3D on scratch, And how it's professionally accomplished
Kinda fixed the rays, but it goes through walls for some reason