Debugger doesn't match code

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

I’m trying to get the collision mask of an object through code, but it does not match what is shown in the debugger. Just as a means of testing I wrote this:

print(obj_coll.get_collision_mask())

I run this and it returns an Int32.MaxValue (2,147,483,647), which doesn’t make sense to me even as a default value (surely this suggests that there are 32 masks and all bits are high). Anyway I put a breakpoint on this line and inspected the node in the debugger, and the debugger (correctly) tells me that the mask is 128.

Why is there this discrepency? My code is failing, because the collision mask property does not reflect what is actually happening in-game.

There is not enough info in your question to figure out what’s wrong. The error is elsewhere.
Is it 2D or 3D? Which code is surrounding that snippet? Are you changing masks from code? What type of object is obj_coll? Is your breakpoint placed exactly on the print? Did you try this in a minimal test project?

Zylann | 2021-01-27 02:11

This sounds similar to a bug that was fixed in 3.2.4beta1 and later: Random scene files are starting mask/layer as 2^31 and not zero · Issue #41281 · godotengine/godot · GitHub

Calinou | 2021-01-27 16:37

Thanks Calinou! I looked through that post and I’m almost positive it’s the same thing. I investigated this more over my lunch hour and I ended up finding that (much like the linked issue) it was something to do with setting the layers in the editor. I noticed that “refresh” sort of icon next to the layers appeared only sometimes, but I just couldn’t figure out exactly what was going on. I’m on version 3.2.2, so this all fits. I’m going to upgrade and see if that fixes it. Thanks so much!

ojn17041991 | 2021-01-27 19:19