#How can i set layer or mask in code?
15 messages · Page 1 of 1 (latest)
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
Inherits: Node2D< CanvasItem< Node< Object Inherited By: Area2D, PhysicsBody2D Base node for 2D collision objects. Description: CollisionObject2D is the base class for 2D physics objects. It can ho...
so how can i set it for my line?
arrow_instance.get_node("/root/Arrow").get_collision_layer_value(1)
is that set?
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)
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")