Godot 3D character falling through platforms. (SOLVED!)

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By yofako


Need Help w godot character falling through scenery. Character walks over two identical bridges. On the first one, no problem. On the second one, he starts to fall through about halfway across the object, then falls. These are identical bridge objects – the same in every way. Happens with 10ish other objects in the level as well but the level has dozens of identical objects that don’t have this problem. Doesn’t happen in any other level. Collision shapes are not scaled and don’t deactivate. It also happens to some parts of the hTerrain object but not others.

Update: It seems to be based on location. If I take that bridge and move it elsewhere in the level, it works fine. If I move a different (working) bridge into its spot, it suddenly has that problem. It happens to other bridges and platforms (a different but similar object) in that area of the level but not elsewhere in the level. This is why I’m so stumped.

Like I said, this game does not have this problem in any other scene or level. I’ve tested the collision objects by attaching mesh instances to them (to make them visible) and they don’t seem to disappear at all.

Update: it happens to enemies as well. They only fall through those certain objects, same as the player, so it isn’t a problem with my player object. Rigid bodies also fall through.

PS I have a gif of this happening but don’t know how to post them here.

Let’s just do what devs do and work the problem. Take your collision objects and move them in and out of the affected area. Do they start and stop working? Or are some always working and some always not? Is it all objects / is it some. You get the idea.

If it’s position, what is it about that position? Check if anything else is there. Is there a GUI?

Just carry on the process of elimination until you can say exactly what the bug is.

Sorry to be vague but there’s not enough info to know without you working the issue / sharing suspect code.

DaddyMonster | 2022-07-22 22:56

I’ve done all that. That’s why I’m asking for help. I’ve tested everything I can think of. If I move a platform out of the area, it works. If I move a working one into the area, it doesn’t. I’ve checked that the collision shapes don’t move or change or deactivate. If I take those same bridge objects into any other level, they work fine, even when placed at the same xyz value as they are in the level where they don’t work. I’ve tried deleting everything out of the problem level that is unique to that level. There is nothing in particular about the positions that the problem is happening, except that it seems to be an area going diagonally down-right through the level about 40-50 units wide. It will affect only the portions of the object that are in that area, and not the portions outside of it. There’s no single object that covers such an area, nor any code that references that area. And these objects are not complicated. They are simple StaticBody objects with some models and a collision object and no script. I’m completely at a loss.

yofako | 2022-07-23 02:55


Holy Crapola.

Just in case this happens to anyone else, here’s how I solved it. Daddymonster was right – I hadn’t tried everything. To solve this, I went through the level and found each object type that was unique to this level. Then I mass-deleted each type, testing the level after each delete, until the level worked! The problematic object was a half-bridge, where the other half appears when you hit a switch. So I deleted just the script from that and tested it, and the level worked, so I knew the problem was in the script.

Here’s the solution: In the script I had set the appearing half to scale = 0,0,0, and when you hit the switch, it expands to scale = 1,1,1 and fills the gap. When I set it to start at scale = anything other than zero, all problems stopped! This eluded me because the appearing bridge object NEVER had the problem of the player falling through it – only other objects in the level had the problem.

SOLUTION: NEVER SET ANYTHING IN YOUR LEVEL TO SCALE = 0,0,0. Set it to visible = false instead!

yofako | 2022-07-23 04:09

Wow, that sounds like an epic journey! Feel good when you finally crack a tough nut.

Yup, setting scale to zero guarantees problems. As you say, never ever do it. You’ll have a broken transformation matrix. It’ll mess up the children and anything that is interacting with the object, their matrices will be multiplied by zero. Normalisation / length will give a div by zero error so basically nothing will work.

You have collision layer / mask values to turn off and on collision and the visibility bool for the mesh as you say. Lesson learnt the hard way. :slight_smile:

DaddyMonster | 2022-07-23 10:31

1 Like