summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Luevano Alvarado <david@luevano.xyz>2023-08-29 04:17:09 -0600
committerDavid Luevano Alvarado <david@luevano.xyz>2023-08-29 04:17:09 -0600
commite6fb8b69c85894994d649b4c7c59a6a1fa606c34 (patch)
treeda723dabaac5128634eddeecf9f982f899f604cf
parent06184c13af639917e1af5a1bc298b0022c1398ea (diff)
add godot layer notes
-rw-r--r--db/db_blog.psv3
-rw-r--r--live/blog/g/flappybird_godot_devlog_2.html10
-rw-r--r--live/blog/g/godot_layers_and_masks_notes.html164
-rw-r--r--live/blog/index.html1
-rw-r--r--live/blog/rss.xml26
-rw-r--r--live/blog/sitemap.xml8
-rw-r--r--live/blog/tag/@english.html1
-rw-r--r--live/blog/tag/@gamedev.html1
-rw-r--r--live/blog/tag/@gdscript.html1
-rw-r--r--live/blog/tag/@godot.html1
-rw-r--r--src/blog/g/flappybird_godot_devlog_2.md2
-rw-r--r--src/blog/g/godot_layers_and_masks_notes.md25
-rw-r--r--src/blog/temp/godot_collision_layers_notes.md12
13 files changed, 237 insertions, 18 deletions
diff --git a/db/db_blog.psv b/db/db_blog.psv
index cd255e5..16f2921 100644
--- a/db/db_blog.psv
+++ b/db/db_blog.psv
@@ -27,4 +27,5 @@ a/arch_logs_flooding_disk.md|1686824540.5338242|1686824666.933781|261eeee98ecbb2
a/torrenting_with_qbittorrent.md|1690164384.3800702|1690170668.4089742|413b7f2764a40fea97f2a22a942ff305|code,english,server,tools,tutorial
a/jellyfin_server_with_sonarr_radarr.md|1690173014.2185652|1690173137.3785434|831c3b7c4183648dbc3be4547fe50686|code,english,server,tools,tutorial
a/pastebin_alt_with_privatebin.md|1692524793.86829|1692527331.9501805|7605e02fc2b613617be56fdf43471664|code,english,server,tools,tutorial
-g/flappybird_godot_devlog_2.md|1693178890.8924305|1693183054.9629443|f4e75adc747b9bf150a7126667185039|english,gamedev,gdscript,godot
+g/flappybird_godot_devlog_2.md|1693178890.8924305|1693304066.9573946|a1b0a6483829aea59a6251b47da210c6|english,gamedev,gdscript,godot
+g/godot_layers_and_masks_notes.md|1693303806.3574584|0.0|407b8f66cdde17ac2f8c113921805d98|english,gamedev,gdscript,godot
diff --git a/live/blog/g/flappybird_godot_devlog_2.html b/live/blog/g/flappybird_godot_devlog_2.html
index b7a5047..d4f764b 100644
--- a/live/blog/g/flappybird_godot_devlog_2.html
+++ b/live/blog/g/flappybird_godot_devlog_2.html
@@ -116,7 +116,7 @@
</ul>
</div>
<h2 id="porting-to-godot-4">Porting to Godot 4<a class="headerlink" href="#porting-to-godot-4" title="Permanent link">&para;</a></h2>
-<p><strong>Disclaimer:</strong> I started the port back in <em>Godot 4.0</em> something and left the project for a while, then opened the project again in <em>Godot 4.1</em>, and it didn&rsquo;t ask to convert anything so probably nowadays the conversion is better.</p>
+<p><strong>Disclaimer:</strong> I started the port back in <em>Godot 4.0</em> something and left the project for a while, then opened the project again in <em>Godot 4.1</em>, and it didn&rsquo;t ask to convert anything so probably nowadays the conversion is better. Godot&rsquo;s documentation is pretty useful, I looked at the <a href="https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html">GDScript reference</a> and <a href="https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html">GDScript exports</a> and that helped a lot.</p>
<h3 id="general-changes">General changes<a class="headerlink" href="#general-changes" title="Permanent link">&para;</a></h3>
<p>These include the first changes for fixing some of the conflicting code to at least make it run (no gameplay) as well as project settings adjustments.</p>
<ul>
@@ -278,6 +278,12 @@ AudioServer.set_bus_mute(_bus, true) # false to unmute
</ul>
<div class="page-nav">
+ <span class="next">
+ <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html" alt="Next">
+ <i class="fas fa-arrow-left" alt="Arrow left"></i>
+ <span>Next</span>
+ </a>
+ </span>
<span class="index">
<a href="https://blog.luevano.xyz" alt="Index">
@@ -299,7 +305,7 @@ AudioServer.set_bus_mute(_bus, true) # false to unmute
<div class="article-info">
<p>By David Luévano</p>
<p>Created: Sun, Aug 27, 2023 @ 23:28 UTC</p>
- <p>Modified: Mon, Aug 28, 2023 @ 00:37 UTC</p>
+ <p>Modified: Tue, Aug 29, 2023 @ 10:14 UTC</p>
<div class="article-tags">
<p>Tags:
<a href="https://blog.luevano.xyz/tag/@english.html">english</a>, <a href="https://blog.luevano.xyz/tag/@gamedev.html">gamedev</a>, <a href="https://blog.luevano.xyz/tag/@gdscript.html">gdscript</a>, <a href="https://blog.luevano.xyz/tag/@godot.html">godot</a> </p>
diff --git a/live/blog/g/godot_layers_and_masks_notes.html b/live/blog/g/godot_layers_and_masks_notes.html
new file mode 100644
index 0000000..f13805e
--- /dev/null
+++ b/live/blog/g/godot_layers_and_masks_notes.html
@@ -0,0 +1,164 @@
+<!DOCTYPE html>
+<html class="theme-dark" lang="en
+"
+ prefix="og: https://ogp.me/ns#">
+ <head>
+ <meta charset="utf-8">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <link rel="icon" href="https://static.luevano.xyz/images/icons/favicon.ico">
+<title>Godot layers and masks notes -- Luévano's Blog</title>
+ <meta name="description" content="Some notes I took regarding Godot's confusing collision layers and masks."/>
+<link rel="alternate" type="application/rss+xml" href="https://blog.luevano.xyz/rss.xml" title="Luévano's Blog RSS">
+ <!-- general style -->
+ <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/style.css">
+ <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/fork-awesome/css/fork-awesome.min.css">
+ <link rel="stylesheet" type="text/css" href="https://static.luevano.xyz/font-awesome/css/all.min.css">
+ <!-- theme related -->
+ <script type="text/javascript" src="https://static.luevano.xyz/scripts/theme.js"></script>
+ <link id="theme-css" rel="stylesheet" type="text/css" href="https://static.luevano.xyz/css/theme.css">
+ <!-- misc functions-->
+ <script type="text/javascript" src="https://static.luevano.xyz/scripts/return_top.js"></script>
+ <!-- extra -->
+
+
+ <!-- highlight support for code blocks -->
+<script type="text/javascript" src="https://static.luevano.xyz/hl/highlight.min.js"></script>
+<script type="text/javascript">
+ hljs.initHighlightingOnLoad();
+</script>
+<link id="code-theme-css" rel="stylesheet" type="text/css" href="https://static.luevano.xyz/hl/styles/nord.min.css">
+
+
+ <!-- Specific to GDScript -->
+ <script type="text/javascript" src="https://static.luevano.xyz/hl/languages/gdscript.min.js"></script>
+
+ <!-- og meta -->
+ <meta property="og:title" content="Godot layers and masks notes -- Luévano's Blog"/>
+ <meta property="og:type" content="article"/>
+ <meta property="og:url" content="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.md"/>
+ <meta property="og:image" content="https://static.luevano.xyz/images/b/default.png"/>
+ <meta property="og:description" content="Some notes I took regarding Godot's confusing collision layers and masks."/>
+ <meta property="og:locale" content="en"/>
+ <meta property="og:site_name" content="Luévano's Blog"/>
+ </head>
+
+ <body>
+ <header>
+<nav>
+ <ul>
+ <li>
+ <a href="https://luevano.xyz/"><i class="fas fa-home" alt="Home"></i><span>Home</span></a>
+ </li>
+
+ <li>
+ <a href="https://blog.luevano.xyz/"><i class="fas fa-book-open" alt="Blog"></i><span>Blog</span></a>
+ </li>
+
+ <li>
+ <a href="https://art.luevano.xyz/"><i class="fas fa-paint-brush" alt="Art"></i><span>Art</span></a>
+ </li>
+
+ <li><i class="fab fa-git" alt="Git"></i><span>Git</span>
+ <ul>
+ <li><a href="https://git.luevano.xyz/" target="_blank"><i class="fab fa-git-alt" alt="Git-alt"></i></a></li>
+
+ <li><a href="https://github.com/luevano" target="_blank"><i class="fab fa-github" alt="Github"></i></a></li>
+
+ <li><a href="https://gitlab.com/dluevano" target="_blank"><i class="fab fa-gitlab" alt="Gitlab"></i></a></li>
+ </ul>
+ </li>
+
+ <li><i class="fas fa-box-open" alt="Stuff"></i><span>Stuff</span>
+ <ul>
+ <li><a href="https://gb.luevano.xyz/"><i class="fas fa-gamepad" alt="Gameboy"></i><span>Gameboy</span></a></li>
+ </ul>
+ </li>
+ </ul>
+</nav>
+
+<button class="theme-switcher" onclick="toggleTheme()"><i class="fas fa-moon"></i><i class="fas fa-sun"></i></button>
+
+ </header>
+
+ <main>
+ <div class="return-top">
+ <button class="return-top" onclick="returnTop()" id="returnTopButton">
+ <i class="fas fa-arrow-up" alt="Return to top"></i>
+ </button>
+ </div>
+ <h1>Godot layers and masks notes</h1>
+
+ <p>The first time I learned about Godot&rsquo;s collision layers and masks (will refer to them just as layers) I thought I understood them only to find out that they&rsquo;re a bit confusing when trying to figure out interactions between objects that are supposed to detect each other. On my last entry where I <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">ported the FlappyBird clone to <em>Godot 4.1</em></a> I stumbled upon an issue with the bird not colliding properly with the pipes and the ceiling detector not&hellip; well, detecting.</p>
+<p>At the end of the day the issue wasn&rsquo;t that the layers weren&rsquo;t properly setup but rather that the API to change the state of the collision layers changed between <em>Godot 3</em> and <em>Godot 4</em>: when calling <code>set_collision_layer_value</code> (or <code>.._mask</code>) instead of specifying the <code>bit</code> which starts at <code>0</code>, the <code>layer_number</code> is required that happens to start at <code>1</code>. This was a headache for like an hour and made me realise that I didn&rsquo;t understand layers that well or else I would&rsquo;ve picked the error almost instantly.</p>
+<p>While researching I found two really good short explainations that helped me grasp the concepts better in the same <a href="https://ask.godotengine.org/4010/whats-difference-between-collision-layers-collision-masks">post</a>, the first a bit technical (by <a href="https://ask.godotengine.org/user/Bojidar+Marinov">Bojidar Marinov</a>):</p>
+<ul>
+<li>If enemy&rsquo;s mask and object&rsquo;s mask are set to <code>0</code> (i.e. no layers), they will still collide with the player, because the player&rsquo;s mask still includes their respective layers.</li>
+<li>Overall, if the objects are <code>A</code> and <code>B</code>, the check for collision is <code>A.mask &amp; B.layers || B.mask &amp; A.layers</code>, where <code>&amp;</code> is bitwise-and, and <code>||</code> is the or operator. I.e. it takes the layers that correspond to the other object&rsquo;s mask, and checks if any of them is on in both places. It will then proceed to check it the other way around, and if any of the two tests passes, it would report the collision.</li>
+</ul>
+<p>And the second, shorter and less technical but still powerful (in the same post linking back to <a href="https://kidscancode.org/blog/2018/02/godot3_kinematic2d/">Godot 3.0: Using KinematicBody2D</a>):</p>
+<ul>
+<li><code>collision_layer</code> describes the layers that the object appears in. By default, all bodies are on layer <code>1</code>.</li>
+<li><code>collision_mask</code> describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer <code>1</code>.</li>
+</ul>
+<p>While the complete answer is the first, as that is how layers work, the second can be used like a rule: 1) the <code>layer</code> is where the object lives, while 2) the <code>mask</code> is what the object will detect.</p>
+
+ <div class="page-nav">
+
+ <span class="index">
+ <a href="https://blog.luevano.xyz" alt="Index">
+ <i class="fas fa-home" alt="Home"></i>
+ <span>Index</span>
+ </a>
+ </span>
+
+ <span class="previous">
+ <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html" alt="Previous">
+ <i class="fas fa-arrow-right" alt="Arrow right"></i>
+ <span>Previous</span>
+ </a>
+ </span>
+</div>
+
+
+ <hr>
+ <div class="article-info">
+ <p>By David Luévano</p>
+ <p>Created: Tue, Aug 29, 2023 @ 10:10 UTC</p>
+ <div class="article-tags">
+ <p>Tags:
+<a href="https://blog.luevano.xyz/tag/@english.html">english</a>, <a href="https://blog.luevano.xyz/tag/@gamedev.html">gamedev</a>, <a href="https://blog.luevano.xyz/tag/@gdscript.html">gdscript</a>, <a href="https://blog.luevano.xyz/tag/@godot.html">godot</a> </p>
+</div>
+
+ </div>
+ </main>
+
+ <footer>
+<span>
+ <i class="fas fa-address-card" alt="Contact"></i>
+ <a href="https://blog.luevano.xyz/contact.html">Contact</a>
+</span>
+
+<span>
+ <i class="fas fa-donate" alt="Donate"></i>
+ <a href="https://blog.luevano.xyz/donate.html">Donate</a>
+</span>
+
+<span>
+ <i class="fas fa-rss" alt="RSS"></i>
+ <a target="_blank" href="https://blog.luevano.xyz/rss.xml">RSS</a>
+</span>
+
+<br>
+<span class="created-with">
+ <i class="fas fa-hammer" alt="Hammer"></i>
+ Created with <a href="https://github.com/luevano/pyssg">pyssg</a>
+</span>
+
+<br>
+<span class="copyright">
+ Copyright <i class="far fa-copyright" alt="Copyright"></i> 2023 David Luévano Alvarado
+</span>
+
+ </footer>
+ </body>
+</html> \ No newline at end of file
diff --git a/live/blog/index.html b/live/blog/index.html
index 62e68e7..6b32ad9 100644
--- a/live/blog/index.html
+++ b/live/blog/index.html
@@ -88,6 +88,7 @@
<h2>Articles</h2>
<ul class="page-list">
<h3>2023</h3>
+ <li><span class="page-list-item">Aug 29</span> - <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html">Godot layers and masks notes</a></li>
<li><span class="page-list-item">Aug 27</span> - <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">Porting the FlappyBird clone to Godot 4.1 devlog 2</a></li>
<li><span class="page-list-item">Aug 20</span> - <a href="https://blog.luevano.xyz/a/pastebin_alt_with_privatebin.html">Set up a pastebin alternative with PrivateBin and YOURLS</a></li>
<li><span class="page-list-item">Jul 24</span> - <a href="https://blog.luevano.xyz/a/jellyfin_server_with_sonarr_radarr.html">Set up a media server with Jellyfin, Sonarr and Radarr</a></li>
diff --git a/live/blog/rss.xml b/live/blog/rss.xml
index 82a3256..e646e8e 100644
--- a/live/blog/rss.xml
+++ b/live/blog/rss.xml
@@ -23,6 +23,30 @@
<link>https://blog.luevano.xyz</link>
</image>
<item>
+ <title>Godot layers and masks notes</title>
+ <link>https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html</link>
+ <guid isPermaLink="true">https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html</guid>
+ <pubDate>Tue, 29 Aug 2023 10:10:06 GMT</pubDate>
+ <category>English</category>
+ <category>Gamedev</category>
+ <category>Gdscript</category>
+ <category>Godot</category>
+ <description>Some notes I took regarding Godot's confusing collision layers and masks.</description>
+ <content:encoded><![CDATA[<p>The first time I learned about Godot&rsquo;s collision layers and masks (will refer to them just as layers) I thought I understood them only to find out that they&rsquo;re a bit confusing when trying to figure out interactions between objects that are supposed to detect each other. On my last entry where I <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">ported the FlappyBird clone to <em>Godot 4.1</em></a> I stumbled upon an issue with the bird not colliding properly with the pipes and the ceiling detector not&hellip; well, detecting.</p>
+<p>At the end of the day the issue wasn&rsquo;t that the layers weren&rsquo;t properly setup but rather that the API to change the state of the collision layers changed between <em>Godot 3</em> and <em>Godot 4</em>: when calling <code>set_collision_layer_value</code> (or <code>.._mask</code>) instead of specifying the <code>bit</code> which starts at <code>0</code>, the <code>layer_number</code> is required that happens to start at <code>1</code>. This was a headache for like an hour and made me realise that I didn&rsquo;t understand layers that well or else I would&rsquo;ve picked the error almost instantly.</p>
+<p>While researching I found two really good short explainations that helped me grasp the concepts better in the same <a href="https://ask.godotengine.org/4010/whats-difference-between-collision-layers-collision-masks">post</a>, the first a bit technical (by <a href="https://ask.godotengine.org/user/Bojidar+Marinov">Bojidar Marinov</a>):</p>
+<ul>
+<li>If enemy&rsquo;s mask and object&rsquo;s mask are set to <code>0</code> (i.e. no layers), they will still collide with the player, because the player&rsquo;s mask still includes their respective layers.</li>
+<li>Overall, if the objects are <code>A</code> and <code>B</code>, the check for collision is <code>A.mask &amp; B.layers || B.mask &amp; A.layers</code>, where <code>&amp;</code> is bitwise-and, and <code>||</code> is the or operator. I.e. it takes the layers that correspond to the other object&rsquo;s mask, and checks if any of them is on in both places. It will then proceed to check it the other way around, and if any of the two tests passes, it would report the collision.</li>
+</ul>
+<p>And the second, shorter and less technical but still powerful (in the same post linking back to <a href="https://kidscancode.org/blog/2018/02/godot3_kinematic2d/">Godot 3.0: Using KinematicBody2D</a>):</p>
+<ul>
+<li><code>collision_layer</code> describes the layers that the object appears in. By default, all bodies are on layer <code>1</code>.</li>
+<li><code>collision_mask</code> describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer <code>1</code>.</li>
+</ul>
+<p>While the complete answer is the first, as that is how layers work, the second can be used like a rule: 1) the <code>layer</code> is where the object lives, while 2) the <code>mask</code> is what the object will detect.</p>]]></content:encoded>
+ </item>
+ <item>
<title>Porting the FlappyBird clone to Godot 4.1 devlog 2</title>
<link>https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html</link>
<guid isPermaLink="true">https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html</guid>
@@ -60,7 +84,7 @@
</ul>
</div>
<h2 id="porting-to-godot-4">Porting to Godot 4<a class="headerlink" href="#porting-to-godot-4" title="Permanent link">&para;</a></h2>
-<p><strong>Disclaimer:</strong> I started the port back in <em>Godot 4.0</em> something and left the project for a while, then opened the project again in <em>Godot 4.1</em>, and it didn&rsquo;t ask to convert anything so probably nowadays the conversion is better.</p>
+<p><strong>Disclaimer:</strong> I started the port back in <em>Godot 4.0</em> something and left the project for a while, then opened the project again in <em>Godot 4.1</em>, and it didn&rsquo;t ask to convert anything so probably nowadays the conversion is better. Godot&rsquo;s documentation is pretty useful, I looked at the <a href="https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html">GDScript reference</a> and <a href="https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html">GDScript exports</a> and that helped a lot.</p>
<h3 id="general-changes">General changes<a class="headerlink" href="#general-changes" title="Permanent link">&para;</a></h3>
<p>These include the first changes for fixing some of the conflicting code to at least make it run (no gameplay) as well as project settings adjustments.</p>
<ul>
diff --git a/live/blog/sitemap.xml b/live/blog/sitemap.xml
index 0f0ece6..7131e1d 100644
--- a/live/blog/sitemap.xml
+++ b/live/blog/sitemap.xml
@@ -46,8 +46,14 @@
</url>
<url>
+ <loc>https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html</loc>
+ <lastmod>2023-08-29</lastmod>
+ <changefreq>weekly</changefreq>
+ <priority>1.0</priority>
+ </url>
+ <url>
<loc>https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html</loc>
- <lastmod>2023-08-28</lastmod>
+ <lastmod>2023-08-29</lastmod>
<changefreq>weekly</changefreq>
<priority>1.0</priority>
</url>
diff --git a/live/blog/tag/@english.html b/live/blog/tag/@english.html
index 2f98448..10f4aef 100644
--- a/live/blog/tag/@english.html
+++ b/live/blog/tag/@english.html
@@ -78,6 +78,7 @@
<h2>Articles</h2>
<ul class="page-list">
<h3>2023</h3>
+ <li><span class="page-list-item">Aug 29</span> - <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html">Godot layers and masks notes</a></li>
<li><span class="page-list-item">Aug 27</span> - <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">Porting the FlappyBird clone to Godot 4.1 devlog 2</a></li>
<li><span class="page-list-item">Aug 20</span> - <a href="https://blog.luevano.xyz/a/pastebin_alt_with_privatebin.html">Set up a pastebin alternative with PrivateBin and YOURLS</a></li>
<li><span class="page-list-item">Jul 24</span> - <a href="https://blog.luevano.xyz/a/jellyfin_server_with_sonarr_radarr.html">Set up a media server with Jellyfin, Sonarr and Radarr</a></li>
diff --git a/live/blog/tag/@gamedev.html b/live/blog/tag/@gamedev.html
index 512bd9c..b4141f6 100644
--- a/live/blog/tag/@gamedev.html
+++ b/live/blog/tag/@gamedev.html
@@ -78,6 +78,7 @@
<h2>Articles</h2>
<ul class="page-list">
<h3>2023</h3>
+ <li><span class="page-list-item">Aug 29</span> - <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html">Godot layers and masks notes</a></li>
<li><span class="page-list-item">Aug 27</span> - <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">Porting the FlappyBird clone to Godot 4.1 devlog 2</a></li>
<h3>2022</h3>
<li><span class="page-list-item">Jun 10</span> - <a href="https://blog.luevano.xyz/g/gogodot_jam3_devlog_1.html">Creating my Go Godot Jam 3 entry using Godot 3.5 devlog 1</a></li>
diff --git a/live/blog/tag/@gdscript.html b/live/blog/tag/@gdscript.html
index f004012..3866b7c 100644
--- a/live/blog/tag/@gdscript.html
+++ b/live/blog/tag/@gdscript.html
@@ -78,6 +78,7 @@
<h2>Articles</h2>
<ul class="page-list">
<h3>2023</h3>
+ <li><span class="page-list-item">Aug 29</span> - <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html">Godot layers and masks notes</a></li>
<li><span class="page-list-item">Aug 27</span> - <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">Porting the FlappyBird clone to Godot 4.1 devlog 2</a></li>
<h3>2022</h3>
<li><span class="page-list-item">Jun 10</span> - <a href="https://blog.luevano.xyz/g/gogodot_jam3_devlog_1.html">Creating my Go Godot Jam 3 entry using Godot 3.5 devlog 1</a></li>
diff --git a/live/blog/tag/@godot.html b/live/blog/tag/@godot.html
index fd622f7..a5f2d67 100644
--- a/live/blog/tag/@godot.html
+++ b/live/blog/tag/@godot.html
@@ -78,6 +78,7 @@
<h2>Articles</h2>
<ul class="page-list">
<h3>2023</h3>
+ <li><span class="page-list-item">Aug 29</span> - <a href="https://blog.luevano.xyz/g/godot_layers_and_masks_notes.html">Godot layers and masks notes</a></li>
<li><span class="page-list-item">Aug 27</span> - <a href="https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html">Porting the FlappyBird clone to Godot 4.1 devlog 2</a></li>
<h3>2022</h3>
<li><span class="page-list-item">Jun 10</span> - <a href="https://blog.luevano.xyz/g/gogodot_jam3_devlog_1.html">Creating my Go Godot Jam 3 entry using Godot 3.5 devlog 1</a></li>
diff --git a/src/blog/g/flappybird_godot_devlog_2.md b/src/blog/g/flappybird_godot_devlog_2.md
index 3363f0e..4532cc5 100644
--- a/src/blog/g/flappybird_godot_devlog_2.md
+++ b/src/blog/g/flappybird_godot_devlog_2.md
@@ -19,7 +19,7 @@ The source code can be found at [luevano/flappybirdgodot](https://github.com/lue
# Porting to Godot 4
-**Disclaimer:** I started the port back in *Godot 4.0* something and left the project for a while, then opened the project again in *Godot 4.1*, and it didn't ask to convert anything so probably nowadays the conversion is better.
+**Disclaimer:** I started the port back in *Godot 4.0* something and left the project for a while, then opened the project again in *Godot 4.1*, and it didn't ask to convert anything so probably nowadays the conversion is better. Godot's documentation is pretty useful, I looked at the [GDScript reference](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_basics.html) and [GDScript exports](https://docs.godotengine.org/en/stable/tutorials/scripting/gdscript/gdscript_exports.html) and that helped a lot.
## General changes
diff --git a/src/blog/g/godot_layers_and_masks_notes.md b/src/blog/g/godot_layers_and_masks_notes.md
new file mode 100644
index 0000000..5c3efd5
--- /dev/null
+++ b/src/blog/g/godot_layers_and_masks_notes.md
@@ -0,0 +1,25 @@
+title: Godot layers and masks notes
+author: David Luévano
+lang: en
+summary: Some notes I took regarding Godot's confusing collision layers and masks.
+tags: gamedev
+ godot
+ gdscript
+ english
+
+The first time I learned about Godot's collision layers and masks (will refer to them just as layers) I thought I understood them only to find out that they're a bit confusing when trying to figure out interactions between objects that are supposed to detect each other. On my last entry where I [ported the FlappyBird clone to *Godot 4.1*](https://blog.luevano.xyz/g/flappybird_godot_devlog_2.html) I stumbled upon an issue with the bird not colliding properly with the pipes and the ceiling detector not... well, detecting.
+
+At the end of the day the issue wasn't that the layers weren't properly setup but rather that the API to change the state of the collision layers changed between *Godot 3* and *Godot 4*: when calling `set_collision_layer_value` (or `.._mask`) instead of specifying the `bit` which starts at `0`, the `layer_number` is required that happens to start at `1`. This was a headache for like an hour and made me realise that I didn't understand layers that well or else I would've picked the error almost instantly.
+
+While researching I found two really good short explainations that helped me grasp the concepts better in the same [post](https://ask.godotengine.org/4010/whats-difference-between-collision-layers-collision-masks), the first a bit technical (by [Bojidar Marinov](https://ask.godotengine.org/user/Bojidar+Marinov)):
+
+- If enemy's mask and object's mask are set to `0` (i.e. no layers), they will still collide with the player, because the player's mask still includes their respective layers.
+- Overall, if the objects are `A` and `B`, the check for collision is `A.mask & B.layers || B.mask & A.layers`, where `&` is bitwise-and, and `||` is the or operator. I.e. it takes the layers that correspond to the other object's mask, and checks if any of them is on in both places. It will then proceed to check it the other way around, and if any of the two tests passes, it would report the collision.
+
+And the second, shorter and less technical but still powerful (in the same post linking back to [Godot 3.0: Using KinematicBody2D](https://kidscancode.org/blog/2018/02/godot3_kinematic2d/)):
+
+- `collision_layer` describes the layers that the object appears in. By default, all bodies are on layer `1`.
+- `collision_mask` describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer `1`.
+
+While the complete answer is the first, as that is how layers work, the second can be used like a rule: 1) the `layer` is where the object lives, while 2) the `mask` is what the object will detect.
+
diff --git a/src/blog/temp/godot_collision_layers_notes.md b/src/blog/temp/godot_collision_layers_notes.md
deleted file mode 100644
index a8df1da..0000000
--- a/src/blog/temp/godot_collision_layers_notes.md
+++ /dev/null
@@ -1,12 +0,0 @@
-# Notes on layers and masks
-
-Taken from a comment from https://ask.godotengine.org/4010/whats-difference-between-collision-layers-collision-masks:
-
-1. If enemy's mask and object's mask are set to 0 (i.e. no layers), they will still collide with the player, because the player's mask still includes their respective layers.
-2. Overall, if the objects are `A` and `B`, the check for collision is `A.mask & B.layers || B.mask & A.layers`, where `&` is bitwise-and, and `||` is the or operator. I.e. it takes the layers that correspond to the other object's mask, and checks if any of them is on in both places. It will they proceed to check it the other way around, and if any of the two tests passes, it would report the collision.
-
-Also, in the same link (which in turn is taken from https://kidscancode.org/blog/2018/02/godot3_kinematic2d/):
-
-1. `collision_layer` describes the layers that the object appears in. By default, all bodies are on layer `1`.
-2. `collision_mask` describes what layers the body will scan for collisions. If an object isn’t in one of the mask layers, the body will ignore it. By default, all bodies scan layer `1`.
-