Discuss Scratch
- EvanTheEevee543
-
Scratcher
75 posts
Walls collision
in my https://scratch.mit.edu/projects/362911146/ game, you can clip through a wall I set up (Its deleted now), how do I make it have collision
- wd4q5dy
-
Scratcher
100+ posts
Walls collision
You just need:
when green flag clickedThat should work, I think.
forever
if <touching color [#000000] ?> then
repeat until <not <touching color [#000000] ?>>
change y by (1)
end
end
end
- EvanTheEevee543
-
Scratcher
75 posts
Walls collision
You just need:It wont, when I try doing that, the player just bobs up and down, and thats for not clipping through the ground, not wallswhen green flag clickedThat should work, I think.
forever
if <touching color [#000000] ?> then
repeat until <not <touching color [#000000] ?>>
change y by (1)
end
end
end
- LordThror
-
Scratcher
100+ posts
Walls collision
I've seen people do something this
And then the if-then statement is repeated a lot.
when green flag clicked
forever
if <<touching color [#58c937] ?>> then
change y by (1)
if <<touching color [#58c937] ?>> then
change y by (1)
end
end
end
And then the if-then statement is repeated a lot.
- EvanTheEevee543
-
Scratcher
75 posts
Walls collision
I've seen people do something thisUgh… It doesn't work! First off, it walls, not groundwhen green flag clicked
forever
if <<touching color [#58c937] ?>> then
change y by (1)
if <<touching color [#58c937] ?>> then
change y by (1)
end
end
end
And then the if-then statement is repeated a lot.
Second, its velocity + scrolling
Third: I want a global sprite, not if touching color
- SpideyPlaysMC
-
Scratcher
500+ posts
Walls collision
You might wanna use this instead:
<touching [ground v] ?> //whatever you name the terrainIt works for scrolling.
Last edited by SpideyPlaysMC (Feb. 9, 2020 15:11:01)
- Queble
-
Scratcher
100+ posts
Walls collision
in my https://scratch.mit.edu/projects/362911146/ game, you can clip through a wall I set up (Its deleted now), how do I make it have collisionJust change Ypos by 1, and repeat this process until the player is not touching the ground sprite.
make sure to put it inside a “run without screen refresh” custom block, and fit it into a forever loop.
- BlueNoodle29
-
Scratcher
100+ posts
Walls collision
You just need:It wont, when I try doing that, the player just bobs up and down, and thats for not clipping through the ground, not wallswhen green flag clickedThat should work, I think.
forever
if <touching color [#000000] ?> then
repeat until <not <touching color [#000000] ?>>
change y by (1)
end
end
end
Because it is a wall not ground, change x pos instead of y
- EvanTheEevee543
-
Scratcher
75 posts
Walls collision
As I said, when I try doing that, the player bobs up and down like a piece of kelp in water in minecraftin my https://scratch.mit.edu/projects/362911146/ game, you can clip through a wall I set up (Its deleted now), how do I make it have collisionJust change Ypos by 1, and repeat this process until the player is not touching the ground sprite.
make sure to put it inside a “run without screen refresh” custom block, and fit it into a forever loop.
- qucchia
-
Scratcher
100+ posts
Walls collision
As I said, when I try doing that, the player bobs up and down like a piece of kelp in water in minecraft
You need to put that code inside a custom block, and check the checkbox that is labelled “Run without screen refresh”.
- charusing
-
New Scratcher
9 posts
Walls collision
You can try this:
´
This only works on this.
———————————
| you |
| | |
| V |
|
|
| |
| |
| |
———————————
´
when green flag clicked
forever
set [ x] to (x position)
set [ y] to (y position)
if <<touching [ v] ?> or <touching color [#457126] ?>> then
go to x: (x) y: (y)
end
set [ x] to (x position)
set [ y] to (y position)
This only works on this.
———————————
| you |
| | |
| V |
|
|| |
| |
| |
———————————
- Neverdeletescratch
-
Scratcher
15 posts
Walls collision
if <> then
<touching [Wall v] ?>
move (-5) steps
end
- queen_slay32
-
New Scratcher
1 post
Walls collision
these comments don't make sense do it properly!!!!!!!!!!
- cool157
-
Scratcher
41 posts
Walls collision
I've seen people do something thisUgh… It doesn't work! First off, it walls, not groundwhen green flag clicked
forever
if <<touching color [#58c937] ?>> then
change y by (1)
if <<touching color [#58c937] ?>> then
change y by (1)
end
end
end
And then the if-then statement is repeated a lot.
Second, its velocity + scrolling
Third: I want a global sprite, not if touching color
Griffpatch made a video that might help
Last edited by cool157 (May 19, 2023 04:59:27)
- gabriel108thedudesss
-
Scratcher
2 posts
Walls collision
in my https://scratch.mit.edu/projects/362911146/ game, you can clip through a wall I set up (Its deleted now), how do I make it have collisioni must be happy
- amogus1123
-
Scratcher
500+ posts
Walls collision
don't necropost.in my https://scratch.mit.edu/projects/362911146/ game, you can clip through a wall I set up (Its deleted now), how do I make it have collisioni must be happy
- NMario84
-
Scratcher
1000+ posts
Walls collision
This is how I would typically set up walls.
As this is just a script for X forward movement running to the right, the same can be applied to Y movement too.
Though maybe your project is handled a bit differently.
———————————————————————————————
EDIT: Oh….. I see…. It's a 5 month old topic bump… Okay then.
when green flag clickedRunning this without screen refresh should help push out the sprite from against the walls.
forever
Movement
end
define Movement
// Run without screen refresh [X]
change x by (10) //runs to the right
repeat until <not <touching [wall v]>>
change x by (-1) //pushes the object/player out of the wall until it is no longer against it.
end
As this is just a script for X forward movement running to the right, the same can be applied to Y movement too.
Though maybe your project is handled a bit differently.
———————————————————————————————
EDIT: Oh….. I see…. It's a 5 month old topic bump… Okay then.
Last edited by NMario84 (Oct. 31, 2023 23:54:37)
- eggylego
-
Scratcher
1 post
Walls collision
You just need:dose not work for mewhen green flag clickedThat should work, I think.
forever
if <touching color [#000000] ?> then
repeat until <not <touching color [#000000] ?>>
change y by (1)
end
end
end
- S742121
-
Scratcher
5 posts
Walls collision
I've seen people do something thisUgh… It doesn't work! First off, it walls, not groundwhen green flag clicked
forever
if <<touching color [#58c937] ?>> then
change y by (1)
if <<touching color [#58c937] ?>> then
change y by (1)
end
end
end
And then the if-then statement is repeated a lot.
Second, its velocity + scrolling
Third: I want a global sprite, not if touching color
the colours of the walls can be very slightly different to the ground and the move Y 1 can be changed to move X 1















