#Changing Projectile Collision Layer&Mask for the Player/Enemy
14 messages · Page 1 of 1 (latest)
My guess would be instantiating it and then calling a function that changes it but it feels inefficient
I don't know how inefficient it would be; it's a one-time call for each projectile, so it's probably not too bad. The functions in question are set_collision_layer_value ( int layer_number, bool value ) and set_collision_mask_value ( int layer_number, bool value )
Thankuuu, I created a function though I can´t call it, any idea why that is?
That´s how I instanciate
but I can´t call any methods from it
This is what I get if I try to call bullet._setLayerMask(2,2) in line 17 of my first screenshot
in Base 'Nil' errors mean that the node wasn't found. So wherever you are assigning the hitbox variable, that code hasn't run yet, or failed to find the node.
Then I´m not sure why o how, since I can manipulate bullet´s position without any problems below those lines
Assuming hitbox is a child node, it's probable that it hasn't created its children yet. What I'd recommend would be setting the layers you want as variables on it, then having the projectile do the actual setting in its _ready() function.