Discuss Scratch
- Discussion Forums
- » Help with Scripts
- » Wall collision detection?
- Peasoncheese
-
Scratcher
4 posts
Wall collision detection?
I'm having trouble finding a script that enables collision detection for a platformer without including several more scripts and/or custom blocks.
As in so you don't go through stuff when you walk up to it… So does anyone have any suggestions?
As in so you don't go through stuff when you walk up to it… So does anyone have any suggestions?
- Finngamer123
-
Scratcher
97 posts
Wall collision detection?
*googles collision detection*
Hm…maybe
Hopes this helps!
Hm…maybe
forever
if <touching [Sprite 2 v] ?> then
Do Something
end
end
Hopes this helps!
- asivi
-
Scratcher
1000+ posts
Wall collision detection?
when [right arrow v] key pressed
repeat until <not <key [right arrow v] pressed?>>
change x by (5)
if <touching color [#ff0088] ?> then // color of wall
change x by (-5) // go back
end
end
- rE201
-
Scratcher
5 posts
Wall collision detection?
when green flag clicked
forever
if < key [ d] pressed?> then
if < touching color [#6d19f7] ?> then
change x by (-5)
Last edited by rE201 (Aug. 17, 2019 19:16:43)
- codeman1044
-
Scratcher
1000+ posts
Wall collision detection?
Please don't necropost.
Hello 60 second rule x4
Hello 60 second rule x4
- gunnerguy2264
-
Scratcher
1 post
Wall collision detection?
I'm currently making a platformer, but when I type
when green flag clickedbut the ground is the same color so my characther will just move backwards even when not touching the wall. Can you help?
forever
if <touching color [#588885] ?> then
change x by (-5)
end
end
Last edited by gunnerguy2264 (Sept. 26, 2019 09:57:16)
- deck26
-
Scratcher
1000+ posts
Wall collision detection?
I'm currently making a platformer, but when I typeYou should create your own topic when you need help.when green flag clickedbut the ground is the same color so my characther will just move backwards even when not touching the wall. Can you help?
forever
if <touching color [#588885] ?> then
change x by (-5)
end
end
If you can't change the colour make the walls and ground sprites instead. The ‘touching sprite’ block is much more efficient anyway.
- Anasolian
-
Scratcher
1 post
Wall collision detection?
when flag clicked change and right arrow pressed, set x velocity to 1, if left pressed, set it to -1, if touching color —— and x velocity > 0, change x by -5, if touching color—– and x velocity < 0 change x by 5…
- officialblueman5
-
Scratcher
1 post
Wall collision detection?
@rE201 that script worked perfectly! thanks!
- SelixScratch
-
Scratcher
100+ posts
Wall collision detection?
Change the X and Y positions separately. Also, add slope functionality, something like this:
change x by (XVel)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (-4)
change x by ((0) - (XVel))
end
Last edited by SelixScratch (June 17, 2020 17:26:07)
- TheColaber
-
Scratcher
500+ posts
Wall collision detection?
Change the X and Y positions separately. Also, add slope functionality, something like this:This topic is from 2016… it should be closedchange x by (XVel)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (-4)
change x by ((0) - (XVel))
end
- scrobotic
-
Scratcher
23 posts
Wall collision detection?
Change the X and Y positions separately. Also, add slope functionality, something like this:Okay, that´s what I need! Thank´s!!change x by (XVel)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (-4)
change x by ((0) - (XVel))
end
- Superlauncher
-
Scratcher
1 post
Wall collision detection?
….
Last edited by Superlauncher (Sept. 9, 2020 16:37:05)
- DeathBlox43
-
Scratcher
26 posts
Wall collision detection?
Change the X and Y positions separately. Also, add slope functionality, something like this:change x by (XVel)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (1)
if <touching [Level v] ?> then
change y by (-4)
change x by ((0) - (XVel))
end
Do you know how to use a similar code with a Scrolling platformer?
- shoto_kazui
-
Scratcher
6 posts
Wall collision detection?
when green flag clicked
forever
if < key [ d] pressed?> then
if < touching color [#6d19f7] ?> then
change x by (-5)
no offense but it dosent work so well but i have a better way
when [ a] key pressed
forever
if <touching [ wall color] ?> then
change x by (10)
end
if <not <key [ a] pressed?> then
stop [ this script]
Last edited by shoto_kazui (Oct. 7, 2020 02:02:57)
- Discussion Forums
- » Help with Scripts
-
» Wall collision detection?