1
\$\begingroup\$

I have a tilemap in Godot 4.1 and I have defined a physics layer for a tileset, but I cannot figure out how to disable a layer in collision mask in code.

I already found out that I should get tileset first and I used this code to set a collision mask to interact with player:

tileset.set_physics_layer_collision_mask(0,2)

But the problem is I don't know how to disable it?

\$\endgroup\$
1
  • \$\begingroup\$ Maybe setting mask to a different one from the player could do the same trick? Or removing the whole layer with remove_physics_layer(int layer_index). \$\endgroup\$ Commented Jul 21, 2023 at 10:31

1 Answer 1

1
\$\begingroup\$

You should be able to set an empty mask.

Here you are setting the mask of the layer 0 to the value 2 (which has only one bit set):

tileset.set_physics_layer_collision_mask(0,2)

Similarly, you can set it 0 so no bit is set:

tileset.set_physics_layer_collision_mask(0,0)

Or you could set some other value if you need to.

\$\endgroup\$

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.