Add/Remove Layers from Layermask in graph?

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

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #12455
    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?

      #12459
      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).

        #12458
        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!

          #12457
          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:

            [attachment file=”2797″]
            [attachment file=”2798″]
            [attachment file=”2799″]
            [attachment file=”2800″]

            [attachment file=”pic5layers.png”]

            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!

            #12456
            Gavalakis
            Keymaster

              Hey,

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

              Thanks!

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