<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Basics on Godot 4 レシピ</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/index.html</link><description>Recent content in Basics on Godot 4 レシピ</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://kamera25.github.io/godot_recipes/4.x/basics/index.xml" rel="self" type="application/rss+xml"/><item><title>Understanding tree order</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/tree_ready_order/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/tree_ready_order/index.html</guid><description>&lt;div class="box notices cstyle tip"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-lightbulb"&gt;&lt;/i&gt; Tip&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This article is being updated from Godot 3 to Godot 4.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You need to understand in what order Godot handles nodes in the scene tree.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;&amp;ldquo;Tree order&amp;rdquo; is mentioned often in the Godot docs and in tutorials. However, it is not always obvious to a beginner what is meant by this. Generally speaking, the order in which nodes are handled in the tree is in &lt;em&gt;top-down&lt;/em&gt; fashion, starting at the root and going down each branch in turn.&lt;/p&gt;</description></item><item><title>Node communication (the right way)</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/node_communication/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/node_communication/index.html</guid><description>&lt;div class="box notices cstyle info"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-info-circle"&gt;&lt;/i&gt; Info&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;Many thanks to @TheDuriel on the &lt;a href="https://discord.gg/zH7NUgz" target="_blank"&gt;Godot Discord&lt;/a&gt; for the &lt;a href="https://kamera25.github.io/godot_recipes/4.x/img/node_access_theduriel.png"&gt;original diagram&lt;/a&gt; that inspired this article. Save this and keep it handy.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;Your project has started getting complex. You have multiple scenes, instances, and a &lt;em&gt;lot&lt;/em&gt; of nodes. You&amp;rsquo;ve probably found yourself writing code like the following:&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-gdscript" data-lang="gdscript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#88c0d0"&gt;get_node&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;../../SomeNode/SomeOtherNode&amp;#34;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#88c0d0"&gt;get_parent&lt;/span&gt;&lt;span style="color:#eceff4"&gt;()&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;get_parent&lt;/span&gt;&lt;span style="color:#eceff4"&gt;()&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;get_node&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;SomeNode&amp;#34;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#88c0d0"&gt;get_tree&lt;/span&gt;&lt;span style="color:#eceff4"&gt;()&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;get_root&lt;/span&gt;&lt;span style="color:#eceff4"&gt;()&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;get_node&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;SomeNode/SomeOtherNode&amp;#34;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;If you do this, you&amp;rsquo;ll soon find that node references like this break easily. As soon as you change one thing about your scene tree, none of those references may be valid anymore.&lt;/p&gt;</description></item><item><title>Understanding node paths</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/getting_nodes/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/getting_nodes/index.html</guid><description>&lt;div class="box notices cstyle tip"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-lightbulb"&gt;&lt;/i&gt; Tip&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This article is being updated from Godot 3 to Godot 4.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s probably the most common problem seen in the Godot help channels: an invalid node reference. Most often, it appears as the following error message:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Invalid get index &amp;lsquo;position&amp;rsquo; (on base: &amp;rsquo;null instance&amp;rsquo;).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;It&amp;rsquo;s that last part, the &amp;ldquo;null instance&amp;rdquo;, that&amp;rsquo;s the source of this problem, and the main source of confusion for Godot beginners.&lt;/p&gt;</description></item><item><title>Understanding 'delta'</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/understanding_delta/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/understanding_delta/index.html</guid><description>&lt;div class="box notices cstyle tip"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-lightbulb"&gt;&lt;/i&gt; Tip&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This article is being updated from Godot 3 to Godot 4.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;The &lt;code&gt;delta&lt;/code&gt; or &amp;ldquo;delta time&amp;rdquo; parameter is a frequently-misunderstood concept in game development. In this tutorial, we&amp;rsquo;ll explain how it&amp;rsquo;s used, the importance of frame-rate independent movement, and practical examples of its use in Godot.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;To illustrate the problem, let&amp;rsquo;s consider a &lt;code&gt;Sprite&lt;/code&gt; node moving across the screen. If our screen is &lt;code&gt;600&lt;/code&gt; pixels wide and we want the sprite to take &lt;code&gt;5&lt;/code&gt; seconds to cross the screen, we can use the following calculation to find the necessary speed:&lt;/p&gt;</description></item><item><title>Saving/loading data</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/file_io/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/file_io/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You need to save and load local data between game sessions.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Godot&amp;rsquo;s file I/O (input/output) system is based around the &lt;code&gt;FileAccess&lt;/code&gt; object. You open a file by calling &lt;code&gt;open()&lt;/code&gt;.&lt;/p&gt;
&lt;div class="highlight"&gt;&lt;pre tabindex="0" style="color:#d8dee9;background-color:#2e3440;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-text-size-adjust:none;"&gt;&lt;code class="language-gdscript" data-lang="gdscript"&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; file &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;FileAccess&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;open&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;user://myfile.name&amp;#34;&lt;/span&gt;&lt;span style="color:#eceff4"&gt;,&lt;/span&gt; File&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;READ&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;
&lt;div class="box notices cstyle warning"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-exclamation-triangle"&gt;&lt;/i&gt; Warning&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;User data should only be stored in the &lt;code&gt;user://&lt;/code&gt; path. While &lt;code&gt;res://&lt;/code&gt; can be used when running from the editor, when your project is exported, the &lt;code&gt;res://&lt;/code&gt; path becomes read-only.&lt;/p&gt;</description></item><item><title>Migrating from 3.x</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/migrating/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/migrating/index.html</guid><description>&lt;p&gt;This is an evolving list of the main changes and &amp;ldquo;gotchas&amp;rdquo; to look out for if you&amp;rsquo;re transitioning to 4.0.&lt;/p&gt;
&lt;h2 id="new-names"&gt;New Names&lt;/h2&gt;
&lt;p&gt;One of the biggest changes in Godot 4 is a whole bunch of renaming - of nodes, functions, and property names. Most of it is done to make things consistent or clear. Here are a few of the biggest ones to watch out for:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;2D/3D nodes - In Godot 3.x, 2D nodes had the &amp;ldquo;2D&amp;rdquo; suffix, but 3D nodes had none. This has been made consistent - they all now have &amp;ldquo;2D&amp;rdquo; or &amp;ldquo;3D&amp;rdquo; suffixes. For example: &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; vs. &lt;i class="gd-RigidBody3D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody3D&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Circular movement</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/rotation/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/rotation/index.html</guid><description>&lt;div class="box notices cstyle tip"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-lightbulb"&gt;&lt;/i&gt; Tip&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This article is being updated from Godot 3 to Godot 4.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want an object to &amp;ldquo;orbit&amp;rdquo; (move in a circle) around another object.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;This is a common beginner question, and often comes after a bunch of messy experimenting with trig functions. The answer is much simpler:&lt;/p&gt;
&lt;p&gt;
&lt;a href="#image-1c2c2ef9c21da43f1088917ef99d839f" class="lightbox-link"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/godot_recipes/3.x/img/circle_motion_01.png" alt="alt" style="height: auto; width: auto;" loading="lazy"&gt;
&lt;/a&gt;
&lt;a href="javascript:history.back();" class="lightbox" id="image-1c2c2ef9c21da43f1088917ef99d839f"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/godot_recipes/3.x/img/circle_motion_01.png" alt="alt" class="lightbox-image" loading="lazy"&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Place the orbiting sprite in a child node of the main sprite (we&amp;rsquo;re calling it &amp;ldquo;Pivot&amp;rdquo;). Give it an offset and rotate the &lt;code&gt;Pivot&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Using Custom Resources</title><link>https://kamera25.github.io/godot_recipes/4.x/basics/custom_resources/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/basics/custom_resources/index.html</guid><description>&lt;div class="box notices cstyle tip"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-lightbulb"&gt;&lt;/i&gt; Tip&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This article is being updated from Godot 3 to Godot 4.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You&amp;rsquo;re looking for a way to handle data and/or create flexible data objects in your game.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Godot&amp;rsquo;s &lt;code&gt;Resource&lt;/code&gt; class is a powerful tool for storing and working with data. Many of the most common objects you work with in Godot extend the &lt;a href="https://docs.godotengine.org/en/stable/classes/class_resource.html#class-resource" target="_blank"&gt;Resource&lt;/a&gt; type: animations, collision shapes, images, etc. Resources not only contain data, but can also manipulate that data (if you&amp;rsquo;re familiar with the concept of &lt;em&gt;scriptable objects&lt;/em&gt; in Unity, the concept is similar).&lt;/p&gt;</description></item></channel></rss>