Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Collision Detection in a Platformer
- SkORINe
-
New Scratcher
34 posts
Collision Detection in a Platformer
Is there a simple script for wall detection that won't let the player through a wall? I can't seem to find a good answer to this.
- drmcw
-
Scratcher
1000+ posts
Collision Detection in a Platformer
The sensor blocks touching sprite or touching color would be the usual ones to use. Look in the sticky topics if that doesn't make sense..
- turkey3
-
Scratcher
1000+ posts
Collision Detection in a Platformer
What physics engine are you using? Can you share the project?
- birchyboii
-
Scratcher
100+ posts
Collision Detection in a Platformer
set the ghost effect of your current sprite to 100, put a colour on each side, we will name the colours 123. 1 - left 2- up 3 - right
In the script I gave you in the other thread it says, if key pressed do this, change it to if key left arrow pressed and colour 1 not touching (wall colour)
repeat for the right.
Now make a slighty (by like 1) smaller identical box and make it go to the hidden one forever.
As for jumping, please reshare your project
In the script I gave you in the other thread it says, if key pressed do this, change it to if key left arrow pressed and colour 1 not touching (wall colour)
repeat for the right.
Now make a slighty (by like 1) smaller identical box and make it go to the hidden one forever.
As for jumping, please reshare your project
- SkORINe
-
New Scratcher
34 posts
Collision Detection in a Platformer
set the ghost effect of your current sprite to 100, put a colour on each side, we will name the colours 123. 1 - left 2- up 3 - rightYeah, here's the game
In the script I gave you in the other thread it says, if key pressed do this, change it to if key left arrow pressed and colour 1 not touching (wall colour)
repeat for the right.
Now make a slighty (by like 1) smaller identical box and make it go to the hidden one forever.
As for jumping, please reshare your project
Last edited by SkORINe (Aug. 21, 2013 14:18:28)
- birchyboii
-
Scratcher
100+ posts
Collision Detection in a Platformer
http://scratch.mit.edu/projects/11936990/
Here, it doesn't detect walls yet but everything else is good!
Here, it doesn't detect walls yet but everything else is good!
- SkORINe
-
New Scratcher
34 posts
Collision Detection in a Platformer
http://scratch.mit.edu/projects/11936990/Ok, thanks. Could you take it down now? Since it's nowhere near finished, could you take it down?
Here, it doesn't detect walls yet but everything else is good!
- michalstaszak
-
New Scratcher
1 post
Collision Detection in a Platformer
i cant find a script block for collision. i did when touching color black then change y by gravity. please help
- Bloxiefox
-
Scratcher
7 posts
Collision Detection in a Platformer
set the ghost effect of your current sprite to 100, put a colour on each side, we will name the colours 123. 1 - left 2- up 3 - right
In the script I gave you in the other thread it says, if key pressed do this, change it to if key left arrow pressed and colour 1 not touching (wall colour)
repeat for the right.
Now make a slighty (by like 1) smaller identical box and make it go to the hidden one forever.
As for jumping, please reshare your project
There isnt any block that checks if a color Isnt touching a color- only
and<color [#00ff00] is touching [#0000ff] ?>
<touching color [#ff0088] ?>
- BKFighter
-
Scratcher
1000+ posts
Collision Detection in a Platformer
First, this is a necropost, second, to prove you wrong:set the ghost effect of your current sprite to 100, put a colour on each side, we will name the colours 123. 1 - left 2- up 3 - right
In the script I gave you in the other thread it says, if key pressed do this, change it to if key left arrow pressed and colour 1 not touching (wall colour)
repeat for the right.
Now make a slighty (by like 1) smaller identical box and make it go to the hidden one forever.
As for jumping, please reshare your project
There isnt any block that checks if a color Isnt touching a color- onlyand<color [#00ff00] is touching [#0000ff] ?>
<touching color [#ff0088] ?>
<not <touching color [#ff0088] ?>>
- cwkzekaryas16115
-
Scratcher
6 posts
Collision Detection in a Platformer
How can I check if my player collides with the flag?
Last edited by cwkzekaryas16115 (June 10, 2020 15:47:48)
- Vibrato
-
Scratcher
1000+ posts
Collision Detection in a Platformer
How can I check if my player collides with the flag?make a new topic for help instead of necroposting, please
- Xx_Shadowy_xX
-
New Scratcher
4 posts
Collision Detection in a Platformer
You Can use A Sensing Block, And Use It To Say:

when green flag clickedSee if that helps
forever
if <touching [Flag v] ?> then
set [Do Something v] to [Anything]
end
end

Last edited by Xx_Shadowy_xX (Sept. 27, 2020 22:39:25)
- Formalbird21-WK
-
New Scratcher
5 posts
Collision Detection in a Platformer
is there anything in this chat that is recent?
- AksharPremnath
-
Scratcher
500+ posts
Collision Detection in a Platformer
is there anything in this chat that is recent?
Please don't necropost
Necroposting is when you post on a topic that has been inactive for a while
When you post on an old topic it puts it back on the first page pushing down newer and more relevant posts
Last edited by AksharPremnath (March 3, 2021 20:39:11)
- ImRohan10187
-
Scratcher
36 posts
Collision Detection in a Platformer
SkORINe, I think this code might help you:
You need to make a variable for gravity called ‘y velocity’
And to simulate gravity acceleration, you can use this code:
You need to make a variable for gravity called ‘y velocity’
And to simulate gravity acceleration, you can use this code:
when green flag clicked
Gravity - Run Without Screen Refresh
[scratchblocks]
define Gravity
forever
change [y velocity v] by (-1)
if <[y velocity] < [-20]> then
set [y velocity v] to [-20]
end
change y by (y velocity)
if <touching [platform v] ?> then
repeat until <not <touching [platform v] ?>>
change y by (1)
set [y velocity v] to [0]
end
end
end
[/scratchblocks]
- gretr234
-
Scratcher
6 posts
Collision Detection in a Platformer
For the flag, just say:
I don't actually mean the variable, I just mean do something
when green flag clicked
if <touching [Flag] ?> then
set [Do something] to [Do something]
end
I don't actually mean the variable, I just mean do something

- TheAnomalousPseudo
-
Scratcher
1000+ posts
Collision Detection in a Platformer
For the flag, just say:The initial post was from 2013. Please do not revive ancient topics.when green flag clicked
if <touching [Flag] ?> then
set [Do something] to [Do something]
end
I don't actually mean the variable, I just mean do something
- Discussion Forums
- » Help with Scripts
-
» Collision Detection in a Platformer














