#How can i set layer or mask in code?

15 messages · Page 1 of 1 (latest)

simple sun
surreal cloud
#

Call get_collision_layer_value(layer_number) and get_collision_mask_value(layer_number) on the node that is your collisionobject

#

layer_number here is the 1 to 32 index of your layer, so not the bitfield value

#

you can also get the collision_layer and collision_mask properties directly on that node, but this is formatted as a bit field so it's more clumsy to work with

simple sun
#

so how can i set it for my line?

#

arrow_instance.get_node("/root/Arrow").get_collision_layer_value(1)

#

is that set?

surreal cloud
#

that is to get, so it will return True or False depending on if it is in layer 1.
To set, you can do arrow_instance.get_node("/root/Arrow").set_collision_layer_value(1, true)

#

or if you want to remove it from the collision layer: arrow_instance.get_node("/root/Arrow").set_collision_layer_value(1, false)

simple sun
#

sorry for dumb question how to access child?

#

nevermind

surreal cloud
#

If your arrow_instance in this case refers to your "Arrow" node that I see in the inspector, then you simply have to do arrow_instance.get_node("Hitbox")

simple sun