This site is currently in read-only mode during migration to a new platform.
You cannot post questions, answers or comments, as they would be lost during the migration otherwise.
0 votes

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.

Godot version 3.2.2
in Engine by (33 points)

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?

This sounds similar to a bug that was fixed in 3.2.4beta1 and later: https://github.com/godotengine/godot/issues/41281

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!

Please log in or register to answer this question.

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.