Add/Remove Layers from Layermask in graph?

FlowCanvas Forums Support Add/Remove Layers from Layermask in graph?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #2751
    elvisish
    Participant

    Is it possible to add or remove layers by name (or int) from a layermask or all layers in a graph? I understand it would require bit shifting:

      <li style=”margin: 0px; padding: 0px; box-sizing: border-box; list-style: outside decimal; vertical-align: top;”>

      layerMask <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>|=</span> <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>(</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #ff0000;”>1</span> <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”><<</span> <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #ff0000;”>8</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>)</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>;</span>

      <li style=”margin: 0px; padding: 0px; box-sizing: border-box; list-style: outside decimal; vertical-align: top;”>

      layerMask <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>=</span> ~<span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>(</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>(</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #ff0000;”>1</span> <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”><<</span> <span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #ff0000;”>9</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>)</span><span style=”margin: 0px; padding: 0px; box-sizing: border-box; color: #008000;”>;</span>

    This way, I could just check for Everything besides layers (so when I add or remove layers, I don’t have to change any layermask references), but I’m not sure if it’s possible to do this with FC currently?

    #2783
    elvisish
    Participant

    It would be very useful for testing against Everything besides a couple of layers, even after more layers have been added to the project (Everything except Enemies and Player, for instance, and at a later date, more layers such as Walls, Floors, Terrain may be added).

    #2789
    Gavalakis
    Keymaster

    Hey,

    I have attached for you here a package which contains some LayerMask method extensions (like Add/Remove to/from LayerMask as well as a ContainsLayer check). Please import the package and the extensions methods will show up under “LayerMask/Methods/Extensions” in the node browser for you to use. You can for example drag and drop a LayerMask output port as normal and under “LayerMask/Methods/Extensions” all the new methods will show up to be used as nodes.

    Please let me know if that works for you 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

    Attachments:
    You must be logged in to view attached files.
    #2796
    elvisish
    Participant

    Sorry for the delay, been dying to try it for the last week and a half and needed to give it a good test! Works AWESOME, I used this to take a layermask Nothing and make it everything besides Water:

    pic1layer
    pic2layer
    pic3layers
    pic4layers

    pic5layers

    Not sure if this is the best way of doing it, but it works for me! This means I never have to worry about adding new layers and going through all of my old layermasks, I can just remove the layers I need excluding at the time. Thanks so much!

    Attachments:
    You must be logged in to view attached files.
    #2805
    Gavalakis
    Keymaster

    Hey,

    I am glad it works for you. Yep that looks correct to me and the way I would do it 🙂

    Thanks!

    Join us on Discord: https://discord.gg/97q2Rjh

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.