Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » How to make a sprite not go through walls?
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
Alright, I'm making a platformer and I'm trying to make my main sprite wall jump and not go through walls. Are there any simple scripts that allow the sprite to wall jump and detect walls?
- 8Bit_Gaming
- Scratcher
90 posts
How to make a sprite not go through walls?
Option 1:
You can use this block:
Option 2:
Make 4 sprites:
Top sensor
Bottom sensor
Left sensor
Right sensor
then make them all be around the player
then in each sensor:
http://wiki.scratch.mit.edu/wiki/Platform_game
https://scratch.mit.edu/projects/635312/
You can use this block:
<touching color [#fffff] ?>if your not using different color walls or if you are using different colors then:
<touching [Walls v] ?>
Option 2:
Make 4 sprites:
Top sensor
Bottom sensor
Left sensor
Right sensor
then make them all be around the player
then in each sensor:
foreverHelp Links:
if <touching [(sensor name) v] ?> then
end
end
http://wiki.scratch.mit.edu/wiki/Platform_game
https://scratch.mit.edu/projects/635312/
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
I'll try that Option 1:
You can use this block:<touching color [#fffff] ?>if your not using different color walls or if you are using different colors then:<touching [Walls v] ?>
Option 2:
Make 4 sprites:
Top sensor
Bottom sensor
Left sensor
Right sensor
then make them all be around the player
then in each sensor:foreverHelp Links:
if <touching [(sensor name) v] ?> then
end
end
http://wiki.scratch.mit.edu/wiki/Platform_game
https://scratch.mit.edu/projects/635312/
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
It worked! Although, I just have one more question, would it be the same script if the platform is inclined or bumpy?I'll try that Option 1:
You can use this block:<touching color [#fffff] ?>if your not using different color walls or if you are using different colors then:<touching [Walls v] ?>
Option 2:
Make 4 sprites:
Top sensor
Bottom sensor
Left sensor
Right sensor
then make them all be around the player
then in each sensor:foreverHelp Links:
if <touching [(sensor name) v] ?> then
end
end
http://wiki.scratch.mit.edu/wiki/Platform_game
https://scratch.mit.edu/projects/635312/
- 8Bit_Gaming
- Scratcher
90 posts
How to make a sprite not go through walls?
Yes,because of the bottom sensor!
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
Yes,because of the bottom sensor!
- ScratchU200
- Scratcher
11 posts
How to make a sprite not go through walls?
This is the best wall detection script, in my opinion:
Hope it helps!
if <touching [the side of the wall v] ?> then
set [variable to control x velocity v] to (((0) - (variable to control x velocity)) * (1.5))
end
Hope it helps!
Last edited by ScratchU200 (Dec. 30, 2015 12:50:50)
- BobaFett-66
- Scratcher
54 posts
How to make a sprite not go through walls?
No No No, this is how u do it with wall sensors on either sides of a sprite:
You will of course have to have the proper movement of the Sprite inside the script swell, I think it works!
when green flag clicked
forever
set [LastX v] to [ (x position)]
set [LastY v] to [ (y position)]
if <touching [Wall v] ?> then
go to x: (LastX) y: (LastY)
end
end
You will of course have to have the proper movement of the Sprite inside the script swell, I think it works!
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
Thanks No No No, this is how u do it with wall sensors on either sides of a sprite:when green flag clicked
forever
set [LastX v] to [ (x position)]
set [LastY v] to [ (y position)]
if <touching [Wall v] ?> then
go to x: (LastX) y: (LastY)
end
end
You will of course have to have the proper movement of the Sprite inside the script swell, I think it works!
- OMYGAWDITSOCUTE
- Scratcher
100+ posts
How to make a sprite not go through walls?
Alright, I'm making a platformer and I'm trying to make my main sprite wall jump and not go through walls. Are there any simple scripts that allow the sprite to wall jump and detect walls?
when green flag clicked
forever
if <touching [walls] ?> then
if <key [up arrow] pressed?> then
change y by (the amount of steps the character goes up, multiplied by negative 1)
end
end
end
- Carpit999
- Scratcher
100+ posts
How to make a sprite not go through walls?
If the wall is on the right side of the screen, you would put this for not going through walls:
when green flag clickedFor wall jump, assuming the wall is 100 y and 50 x, and at x:0 and y:0, and the center is the middle left side, and the character is at x:-20 y:-50(right foot is his center):
forever
if <touching [wall v] ?> then
change x by (any negative number below -9)
end
end
glide (less than 1) secs to x: (-10) y: (80)I haven't tested it. Tell me if it works or doesn't.
glide (less than 0.6) secs to x: (80) y: (80)
glide (same number as the first glide block) secs to x: (80) y: (-50)
- deck26
- Scratcher
1000+ posts
How to make a sprite not go through walls?
Suggest you creste your own topic rather than necroposting. Share what you have so far and describe the problem. None work for me!
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
Ooh someone necroposted on an old topic of mine! xDSuggest you creste your own topic rather than necroposting. Share what you have so far and describe the problem. None work for me!
Wow 1596 views lol
Last edited by Eclipsed6 (Nov. 13, 2017 20:36:45)
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
I would try to help, but I gave up on making proper platformers a while ago XD None work for me!
- deck26
- Scratcher
1000+ posts
How to make a sprite not go through walls?
While you're on here why not close this topic.I would try to help, but I gave up on making proper platformers a while ago XD None work for me!
- Fidjit_3
- New Scratcher
1 post
How to make a sprite not go through walls?
Here's how I do it:
when green flag clicked
forever
if <key [ d] pressed?> then
change x by (3)
if <touching color [#664303] ?> then
change x by (-3)
end
end
end
the color is used as the basic walls for the game. it's not a separate sprite but part of the background:D
- -ShadowOfTheFuture-
- Scratcher
1000+ posts
How to make a sprite not go through walls?
Guys, don't necropost. This topic is from 2015.
- Eclipsed6
- Scratcher
59 posts
How to make a sprite not go through walls?
Someone did necropost, but I'm not going to close this because of that. While you're on here why not close this topic.
- Carpit999
- Scratcher
100+ posts
How to make a sprite not go through walls?
Okay, so I was literally the last post of 2016.
STOP NECROPOSTING!
STOP NECROPOSTING!
- Discussion Forums
- » Help with Scripts
- » How to make a sprite not go through walls?