Open elvisish opened 2 years ago
Related: #3930
Not sure about a CollisionMask Node, per se, but a CollisionMask Resource sounds interesting, to me.
Not sure about a CollisionMask Node, per se, but a CollisionMask Resource sounds interesting, to me.
I love the idea of both, a node though would be great since each instance could have it's own inherited node with differences.
Not sure about a CollisionMask Node, per se, but a CollisionMask Resource sounds interesting, to me.
There is a performance overhead to using resources for this kind of low-level operations, so I'd prefer not. https://github.com/godotengine/godot-proposals/issues/3930 seems like a better solution to the original problem.
3930 seems like a better solution to the original problem.
That still means using code, whereas with this you're just harnessing the simplicity of a visual editor for the layer masking that already exists. I agree it would be nice to use layer names as well, but using a node would be surely the least complicated way of setting up layer masking.
If there's need of a Node that does this, by all means, it doesn't sound that difficult to create your own script for it. However, it seems to me like the problem brought up could be solved by just defining a constant for the mask. The ability of fetching each collision bit by name would certainly make it more readable, too, and I'd favour it over a Node implementation that's a bit... unorthodox compared to the usual workflow.
The ability of fetching each collision bit by name would certainly make it more readable, too.
Yep, if we could do some sort of calculatebitmask("enemy", "neutral", "flying") it would likely solve the OP's use case without Resource overhead.
If there's need of a Node that does this, by all means, it doesn't sound that difficult to create your own script for it. However, it seems to me like the problem brought up could be solved by just defining a constant for the mask. The ability of fetching each collision bit by name would certainly make it more readable, too, and I'd favour it over a Node implementation that's a bit... unorthodox compared to the usual workflow.
So it might be possible to code a custom node that just has a collision mask? I've never written a custom node before, it sounds interesting.
Consider this: If all you really need is to be able to see the collision layer & mask in an easily editable variable, you could create your own Node/Resource that exports just that and fetch it from there in any way it is desirable.
@Mickeon: I fail to see how that helps the OP. He is complaining about bitwise maths and ints being opaque...
Consider this: If all you really need is to be able to see the collision layer & mask in an easily editable variable, you could create your own Node/Resource that exports just that and fetch it from there in any way it is desirable.
That's certainly useful for individual layers, but it still needs bitwise math to combine them into a mask.
@Mickeon: I fail to see how that helps the OP. He is complaining about bitwise maths and ints being opaque...
I wouldn't say complaining, I'm merely suggesting an easier solution would be beneficial to users less experienced with bitwise math and would be on parity with the editor way of setting masks for colliders.
Not sure about a CollisionMask Node, per se, but a CollisionMask Resource sounds interesting, to me.
This has been proposed before, but didn't find much traction: https://github.com/godotengine/godot-proposals/issues/329. I'll close the other one in favor of making this one more open to possibilities.
Describe the project you are working on
First person shooter.
Describe the problem or limitation you are having in your project
Rather than setting unreadable bitwise flags like this:
var monster_mask = 1 << 3 | 1 << 7
It would be far easier and readable to be able to just add a collision mask node and cache it for use. Currently, I'm adding a KinemeticBody node to my object and using it's collision mask:
or
This is really overkill for what needs to just be a basic collision mask node or resource that can be saved and reused later.
Describe the feature / enhancement and how it helps to overcome the problem or limitation
It simplifies the necessity to use bitwise math to create a collision mask.
Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams
As above.
If this enhancement will not be used often, can it be worked around with a few lines of script?
No, it would be a separate node.
Is there a reason why this should be core and not an add-on in the asset library?
It needs to be a node or resource.