Discuss Scratch

DNQ_brwn
Scratcher
18 posts

Need Help with buggy scrolling platformer collisions

Hi, I need help with collision on my Megaman fangame scratch project.

I already did collisions when the player is not scrolling (Scrolling? = false)

but the problem we're facing right now is when you press the slide button and left or right button at the same time when touching a wall, (sometimes) the collision script thinks that the player is crushed and then the player dies instead of moving the player out of the wall no matter how fast the player moves, (because the y hitbox touches the wall first and thinks that it's touching the horizontal ground).

Yes the collision does work in when scrolling or not but it's jittery

Could you fix that?

Here's my scratch project you can remix to fix the problem:
https://scratch-mit-edu.ezproxyberklee.flo.org/projects/1122285765

This is more advanced coding btw.

Last edited by DNQ_brwn (Jan. 19, 2025 18:07:53)

hi_bobux725
Scratcher
100+ posts

Need Help with buggy scrolling platformer collisions

what wall. i only see a void.
DNQ_brwn
Scratcher
18 posts

Need Help with buggy scrolling platformer collisions

.

hi_bobux725 wrote:

what wall. i only see a void.
Sorry, Are you serious?

I'm asking for help on a collision detection script bug, not gameplay.
DNQ_brwn
Scratcher
18 posts

Need Help with buggy scrolling platformer collisions

Ok, I'm sorry to anyone who got confused on which block to fix, It's this block

define Scrolling Move Speed: (speed) Input < Input boolean >
set [wall v] to (< touching [Level v]? > * [1])
if <<<touching [Level v] ?>> or < (Touching?) > [0]>> then
change [ P1 scroll x v] by ([abs v] of ( [floor v] of ( round < input boolean >) * (speed) )) // moves the player out of the wall by putting a negative version of the movement
change [LAST VALUE v] by [1]
set [last value v] to (direction)
point in direction (90)

if <(Slide?) = [false]> then
set [Moving? v] to [Scene-moving]
change [frame v] by [1]
switch costume to ( [98 ]+ (( [floor v] of (frame) )mod [2] ))
change [P1 scroll X v] by (round ((<(costume [name v]) = [X_wallR]> - <(costume [name v]) = [X_wallL]> ) * ([] - (speed) ))) // this move the player out of the wall depending on what costume represents both sides of the player


else

if <(Slide?) = [true]> then
set [Moving? v] to [Scene-moving]
change [frame v] by [1]
switch costume to ( [98 ]+ (( [floor v] of (frame) )mod [2] ))
change [P1 scroll X v] by (round ((<(costume [name v]) = [SlideXR]> - <(costume [name v]) = [SlideXL]> ) * ([] - (speed) ))) // this does the same thing.
end
point in direction (last value) // this resets the player last direction
set [Moving? v] to [true]
end
else
change [ P1 scroll x v] by ((round < input boolean >) * (speed) ) // this lets the player move after moves out of the wall
set [LAST VALUE v] to [0]

In megaman's hitbox costume

Last edited by DNQ_brwn (Jan. 20, 2025 19:46:56)

DNQ_brwn
Scratcher
18 posts

Need Help with buggy scrolling platformer collisions

BUMP, I cannot keep tweaking and figuring out code until the end of time. the project(<- different link) is here so you can remix it and fix it, I actually removed the intro and boss select so you can fix it directly.
but
Note that the hitbox code is based off of specific costumes and that the verticle hitbox (green) assumes the player is dying if the horizontal collision did not succeed the green verticle hitbox tries to move the player only vertically off the wall instead even though the player is still inside the wall., That's the problem.

Last edited by DNQ_brwn (Yesterday 19:16:12)

Powered by DjangoBB