Possible bug, wall collision detection

I noticed that the collision are done only when there is an applied force against what it is colliding. This is actually the way to be yes.
But for some reason this is not true for an specific case, and that kind break things as it is not consistent behavior.

The case is when the character is on ground, when you try to run into the wall it will flag wall collision to true, if you stop moving into it will flag wall collision false, this is expected and fine, but when you do this and stand still next to a wall and jump all of a sudden the wall collision is flagged true and this is not expected, this is not consistent with the collision detection. If it was done on purpose well it is wrong to do so, as I said it is not consistent.

Because of this I will need to create my own physics to detecting collision which is not a way to go as the engine will do a double work , making it heavier than it should.

1 Like

Yes, it is and that was totally unacceptable to me.

And, yes that also happened to me as well. And said as much in one of my posts. I had to find another way to handle wall collisions. By creating a raycast that is only slightly larger than the character facing toward the wall (flipping the raycast when the character is flipped) and detecting whether this raycast is hitting - raycast.is_colliding() - on every frame with the wall, that way you don’t need to be hitting the left/right button or having a force to hit the wall and it always register.

I was disappointed with the approach used in the engine.

I like that design…

What you can do is when collided with wall fire ray towards every frame untill you move away

That’s how you will know if you are still attached to a wall.

That’s how I’d do it.

You seemed not to understand what the problem is. As explained, if the mechanic of collision works one way on the ground so it should work as same when in air.

My guess is that it is different to allow easier , and an automatic stick to the wall. But this is something that is much more complicated if you don’t want that and have to undo what the godot is doing than making what it does if such a thing was not done the way it is. Also it would be consistent with how collision is handle when on ground and when on air.

But answering the addressing the issue at hand I solved without using raycast. You do can use the detection of the wall, but whatever you do anyways must be using some kind of state machine system.

With the state machine you do have much more control of everything and all you need is to know when you touched the wall.
I like to use state machine using the states to separate in such states like ground, air, water, wall and so on. Yes it will be used for some skills like dash or other types, thumb rule here is to use state when ever the player changes state, how it work, if a character change to something that will allow it to move differently so it must be a state.

One example to illustrate it , is to talk about jump, jump is not a state but an ability within a state, which is ground state, similarly double jump is an ability of air state.

So when you are in such air state it will allow and check wall collisions if player is moving in the same direction of the wall then it enter wall state if it is also colliding. Once in this state it will have its own behavior. No need to cast rays every frame, it is too much expensive and there are way better, which is to use the collision checks provided by the engine, because it will do the check anyways if you use that variable to grab the information or not, doing anything extra will just top more work and making a game disregarding the use of already system only adds to slow down the game.

Another thumbs rules is to use as much as possible of the features of the engine because it is expending process either way, so using it instead of creating your way is the best way to make the game more light.

I try to NOT use code in every frame executions as much as possible.

2 Likes