Platformer wall collison?

im having issues with wall collisons in a platformer im making. i cant use key pressed because theres multiple ways you can move without pressing the keys. i tried this script before

(x vel and walking vel are diffrent so doing stuff like friction and other things without effecting other x vel things) this doesnt work as expected tho, ive tried multiple times and all of them didnt work

What does happen?

well if you are holding tward the wall it kind of works, but as soon as you press nothing it pushes you into the wall instead of leaving you outside of the wall, it also just makes it so you can no longer move but i dont think thats related

what does this operator block do ?

add them? i dont see why that would be an issue as the xy velocity movement script also uses that

x velocity isnt x velocity always. its the x velocity that isnt the players input, this is so things can be applied to player movement and not globally to all x velocity

wdym ? like the ( ( ) + ( ) ) operator ? (i don't say this is an issue, i'm just asking cuz i don't know this block)

ohhh

walking velocity is a second variable that handles walking speed and movement

x vel is for non walking things

x vel and walking vel are also seperated to make things like moving platforms easier. and make it so that friction scripts only apply to walking velocity, and not extra velocity the player might have

What do you mean, "as soon as you press nothing"? Do you mean "as soon as you aren't pressing anything"? But on a computer time scale, you're essentially never pressing anything. Whole milliseconds go by between one button press and the next. Do you mean "as soon as two seconds go by without you pressing anything"? I'm not pushing on this detail to be obnoxious; I really need to understand what it is you're asking for help with.

when you are no longer holding an input

do you have a project link?

Ah, I see, thanks.

So, if the horizontal (like "horizon"!) velocity is zero, then that procedure does nothing. If the horizontal velocity is nonzero after you let go of the button, then some other part of the project is moving your sprite, not necessarily in the same direction in which the user was moving deliberately. So I would be inclined to ignore the outside-influence motion in trying to locate the wall (although that's a nice use of the sign function!), but instead keep a variable set by the script that calls MOVE OUT WALL, indicating the direction in which this script has been moving, e.g., if the user pushes the up arrow, set the remembered direction to 90. And move in the opposite direction to get away from the wall.

i think that walking speed sould always be multiplied by friction, and not only when it is greater than the max run speed

1. Create a Minimal reproducible example - Wikipedia to show your problem.
2. Check if your "touching wall" does not test for a collision with the "ground", so you apply wall bounce under the proper conditions.
3. Does your "wall" contain no horizontal lines?
4. Does the speed drop exactly to zero? Or will it stay at a small value and even bounce +/- ?

I think I have an idea, when the player hits a wall they can no longer be moving in the direction of the way. But in order to hit the wall in the first place they have to be moving meaning they have to have some x velocity. So after we move the player out if you set the x velocity and walking velocity to 0 then it should work!

Edit: it worked better but now I can’t walk after hitting the wall

I think I might know why

So what’s probably happening is that when the player presses nothing they don’t move into the wall, but they move a sub pixel away from the wall. They aren’t technically touching it if you were to do the math but they are touching it according to snap because the pixels are touching. Im not exactly sure how to fix this but I imagine will might have something to do with my “value <> is just true” block being put to use

Edit 2: whatever stops my movement IS unrelated to the wall collision script, meaning I kind of solved it but not really

The wall is a rectangle but you don’t ever collide with the top of it

There’s a seperate working script for ground collision

“Touching wall” only contains the sprite(s) that will have wall collision, and touching ground only contains the sprites that will have floor collisions

No sprites should have both or else it would probably break the physics engine

Originally I had it run every time the player touched the wall so if they had positive x velocity or something it would keep it but I’m not making it stop

Now I’m very, very confused

There’s absolutely nothing that effects the walking velocity or x and y velocity and has anything to do with touching walls, I did a test of each block and nothing should be going wrong, yet, it doesn’t work??

Edit: this entire damn time I was setting “walk speed” to 0 and not walking velocity, walk speed is how much the walk velocity increases while the player is holding a direction, so the speed at which the player moves while walking was being set to 0

We've all been there with an issue like that

And now it works perfectly

I spent 5 hours of my fixing a bug that didn’t exist oh my god if I just looked at my variables I would have seen it was zero ahhhh

And we've all done that one as well