Is sprite hitting wall "direction" bug

i don’t know what it is with me, but i keep finding bugs.

i was trying to make somewhat of a custom collision with tiles, where you are affected by gravity if you are NOT hitting wall bottom. but… after “is sprite hitting wall bottom” becomes true, it never becomes false.

no clue why, i remember it working in past projects. here is a piece of code.

and no, its not because it is in an update every x ms block, i have tried it in forever loops and in on game update.

i have also tried making it an if else, and so many other things. at this point i know it is not an issue with my code and i am fairly sure it is an issue with the website itself, or something of the sort.

also, i know it is not ever setting OnGround to false, because i have UI set up to show me the state of it.

2 Likes

Are you ever moving the sprite away from the ground? This may be somewhat of a convenience feature more than a bug, because even if your sprite has 0 speed, you still want to know if it did touch the ground and hasn’t moved off the ground yet.

Please share your code!

2 Likes

I tried replicating the code in another project, and it works, so maybe some of my other code is causing the problem, but I highly doubt that because none of it should be affecting this.

2 Likes

yeah, the sprite is moving off of the ground.
when it hits the ground, then i jump, it is no longer on the ground yet OnGround is still true.

here is the code:

Just an early test version right now. i am attempting to make everything with the physics accurate, but i hit a bit of a bottleneck with this bug.

2 Likes

Could you try sharing your code?
It would help if we could see the rest of the code and find the problem.

1 Like

I gave the cube 0.1 speed and it fixed the issue. I suspect there is something weird going on where the cube isn’t updating its “hitting wall” status unless it moves for a reason other than being teleported. Like, if it clips a tiny bit into the ground and gets pushed out of the ground, it’s “hitting wall” status gets updated, but otherwise, since it’s only being teleported around and is never actually moving with physics and stuff, it never updates its status.

2 Likes

huh, weird. I already found a workaround by placing a sprite at an offset location of the cube, and checking if the tile under it is a wall, but thanks.

1 Like