<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Physics on Godot 4 レシピ</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/index.html</link><description>Recent content in Physics on Godot 4 レシピ</description><generator>Hugo -- gohugo.io</generator><language>en</language><atom:link href="https://kamera25.github.io/godot_recipes/4.x/physics/index.xml" rel="self" type="application/rss+xml"/><item><title>RigidBody2D: Look at Target</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/smooth_rigid_rotate/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/smooth_rigid_rotate/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want a rigid body to rotate smoothly to look at a target.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Using &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; can be tricky. Because it&amp;rsquo;s controlled by Godot&amp;rsquo;s physics engine, you need to apply forces rather than moving it directly. Before doing anything with rigid bodies, I highly recommend looking at the &lt;a href="https://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html" target="_blank"&gt;RigidBody2D API doc&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To rotate a body, we need to apply a rotational force - a &lt;em&gt;torque&lt;/em&gt;. Once the body is rotating, we want the torque to get smaller as we get closer to the final rotation.&lt;/p&gt;</description></item><item><title>CharacterBody3D: Stopping on Slopes</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/kinematicbody_slopes/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/kinematicbody_slopes/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;Your &lt;i class="gd-KinematicBody3D"&gt;&lt;/i&gt;&lt;code&gt;CharacterBody3D&lt;/code&gt; slides down slopes.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;We&amp;rsquo;ve started with a no-frills &lt;i class="gd-KinematicBody3D"&gt;&lt;/i&gt;&lt;code&gt;CharacterBody3D&lt;/code&gt;, using &lt;code&gt;move_and_slide()&lt;/code&gt;, using the script below:&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;extends&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;CharacterBody3D&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#d08770"&gt;@export&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; gravity &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#81a1c1"&gt;-&lt;/span&gt;&lt;span style="color:#b48ead"&gt;10.0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#d08770"&gt;@export&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; speed &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#b48ead"&gt;5.0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#d08770"&gt;@export&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; rot_speed &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#b48ead"&gt;4.0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#d08770"&gt;@export&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; jump_speed &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#b48ead"&gt;5.0&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; velocity &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Vector3&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;ZERO
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; jumping &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;func&lt;/span&gt; &lt;span style="color:#88c0d0"&gt;get_input&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;delta&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:#81a1c1;font-weight:bold"&gt;var&lt;/span&gt; input &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Vector3&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;ZERO
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Input&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;is_action_pressed&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;forward&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; input &lt;span style="color:#81a1c1"&gt;+=&lt;/span&gt; &lt;span style="color:#81a1c1"&gt;-&lt;/span&gt;transform&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;basis&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;z &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; speed
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Input&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;is_action_pressed&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;back&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; input &lt;span style="color:#81a1c1"&gt;+=&lt;/span&gt; transform&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;basis&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;z &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; speed
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Input&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;is_action_pressed&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;right&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;rotate_y&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;-&lt;/span&gt;rot_speed &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; delta&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:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Input&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;is_action_pressed&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;left&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;rotate_y&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;rot_speed &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; delta&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; velocity&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;x &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; input&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;x
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; velocity&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;z &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; input&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;z
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;&lt;span style="color:#81a1c1;font-weight:bold"&gt;func&lt;/span&gt; &lt;span style="color:#88c0d0"&gt;_physics_process&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;delta&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_input&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;delta&lt;span style="color:#eceff4"&gt;)&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; velocity&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;y &lt;span style="color:#81a1c1"&gt;+=&lt;/span&gt; gravity &lt;span style="color:#81a1c1"&gt;*&lt;/span&gt; delta
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&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;move_and_slide&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&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; jumping &lt;span style="color:#81a1c1;font-weight:bold"&gt;and&lt;/span&gt; &lt;span style="color:#88c0d0"&gt;is_on_floor&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; jumping &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;false&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#8fbcbb"&gt;Input&lt;/span&gt;&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;&lt;span style="color:#88c0d0"&gt;is_action_just_pressed&lt;/span&gt;&lt;span style="color:#eceff4"&gt;(&lt;/span&gt;&lt;span style="color:#a3be8c"&gt;&amp;#34;jump&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:#81a1c1;font-weight:bold"&gt;if&lt;/span&gt; &lt;span style="color:#88c0d0"&gt;is_on_floor&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; jumping &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; &lt;span style="color:#81a1c1;font-weight:bold"&gt;true&lt;/span&gt;
&lt;/span&gt;&lt;/span&gt;&lt;span style="display:flex;"&gt;&lt;span&gt; velocity&lt;span style="color:#81a1c1"&gt;.&lt;/span&gt;y &lt;span style="color:#81a1c1"&gt;=&lt;/span&gt; jump_speed
&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;&lt;p&gt;We see the problem if we stop moving on a slope:&lt;/p&gt;</description></item><item><title>Collision Layers and Masks</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/collision_layers/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/collision_layers/index.html</guid><description>&lt;h2 id="introduction"&gt;Introduction&lt;/h2&gt;
&lt;p&gt;Collision layers and masks are essential for controlling which objects interact with each other in Godot 4.&lt;/p&gt;
&lt;h3 id="the-system"&gt;The System&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Collision Layer&lt;/strong&gt;: Which layer(s) the object &lt;strong&gt;lives on&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Collision Mask&lt;/strong&gt;: Which layer(s) the object &lt;strong&gt;scans for collisions&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3 id="example-configuration"&gt;Example Configuration&lt;/h3&gt;
&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th style="text-align: left"&gt;Node&lt;/th&gt;
&lt;th style="text-align: left"&gt;Layer&lt;/th&gt;
&lt;th style="text-align: left"&gt;Mask&lt;/th&gt;
&lt;th style="text-align: left"&gt;Interaction&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td style="text-align: left"&gt;&lt;strong&gt;Player&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align: left"&gt;1&lt;/td&gt;
&lt;td style="text-align: left"&gt;2, 3&lt;/td&gt;
&lt;td style="text-align: left"&gt;Scans for Enemies and Coins&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left"&gt;&lt;strong&gt;Enemy&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align: left"&gt;2&lt;/td&gt;
&lt;td style="text-align: left"&gt;1&lt;/td&gt;
&lt;td style="text-align: left"&gt;Scans for the Player&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td style="text-align: left"&gt;&lt;strong&gt;Coin&lt;/strong&gt;&lt;/td&gt;
&lt;td style="text-align: left"&gt;3&lt;/td&gt;
&lt;td style="text-align: left"&gt;(None)&lt;/td&gt;
&lt;td style="text-align: left"&gt;Doesn&amp;rsquo;t need to scan anything&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;h3 id="setting-names"&gt;Setting Names&lt;/h3&gt;
&lt;p&gt;In Godot 4, you can name your layers in &lt;strong&gt;Project Settings &amp;gt; Layer Names &amp;gt; 2D Physics&lt;/strong&gt;. This makes it much easier to manage in the Inspector.&lt;/p&gt;</description></item><item><title>Kinematic Friction</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/kinematic_friction/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/kinematic_friction/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 to add friction and acceleration to your kinematic character, giving it a smoother feel.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;For most games, we&amp;rsquo;re not necessarily interested in a perfect physics simulation. We want action, responsiveness, and arcade feel. This is why you choose a kinematic body over a rigid one: so that you can control its behavior directly. However, &lt;em&gt;some&lt;/em&gt; amount of physics is good - it means an object doesn&amp;rsquo;t instantly change direction or come to a stop.&lt;/p&gt;</description></item><item><title>RigidBody2D: Move to Target</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/smooth_rigid_move/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/smooth_rigid_move/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want a rigid body to move to a target position.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Using &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; can be tricky. Because it&amp;rsquo;s controlled by Godot&amp;rsquo;s physics engine, you need to apply forces rather than moving it directly. Before doing anything with rigid bodies, I highly recommend looking at the &lt;a href="https://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html" target="_blank"&gt;RigidBody2D API doc&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;To move a body, we need to apply a push in a given direction - a &lt;em&gt;force&lt;/em&gt;. Once the body is moving, we want the force to get smaller as we get closer to the final position.&lt;/p&gt;</description></item><item><title>RigidBody2D: Drag and Drop</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/rigidbody_drag_drop/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/rigidbody_drag_drop/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want to pick up and move rigid bodies with the mouse.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Working with rigid bodies can be tricky. Godot&amp;rsquo;s physics engine controls their movements, and interfering with that can often lead to unexpected results. The key is to make use of the body&amp;rsquo;s &lt;code&gt;mode&lt;/code&gt; property. This applies equally well in 2D or 3D.&lt;/p&gt;
&lt;h3 id="body-setup"&gt;Body setup&lt;/h3&gt;
&lt;p&gt;We&amp;rsquo;ll start with our rigid body object, adding a &lt;i class="gd-Sprite2D"&gt;&lt;/i&gt;&lt;code&gt;Sprite2D&lt;/code&gt; and &lt;i class="gd-CollisionShape2D"&gt;&lt;/i&gt;&lt;code&gt;CollisionShape2D&lt;/code&gt;. You can also add a &lt;code&gt;PhysicsMaterial&lt;/code&gt; if you want to set &lt;em&gt;Bounce&lt;/em&gt; and &lt;em&gt;Friction&lt;/em&gt; properties.&lt;/p&gt;</description></item><item><title>Character to Rigid Body Interaction</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/character_vs_rigid/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/character_vs_rigid/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want your character body to interact with rigid bodies.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;div class="box notices cstyle note"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-exclamation-circle"&gt;&lt;/i&gt; Note&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;This recipe applies equally well in both 2D and 3D nodes.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;By default, a &lt;i class="gd-CharacterBody2D"&gt;&lt;/i&gt;&lt;code&gt;CharacterBody2D&lt;/code&gt; moved with &lt;code&gt;move_and_slide()&lt;/code&gt; or &lt;code&gt;move_and_collide()&lt;/code&gt; will not push any &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; it collides with. The rigid body doesn&amp;rsquo;t react at all, and behaves just like a &lt;i class="gd-StaticBody2D"&gt;&lt;/i&gt;&lt;code&gt;StaticBody2D&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;
&lt;a href="#image-45a48507cf4d317656282db59e25be96" class="lightbox-link"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/char_push_default.gif" alt="alt" style="height: auto; width: auto;" loading="lazy"&gt;
&lt;/a&gt;
&lt;a href="javascript:history.back();" class="lightbox" id="image-45a48507cf4d317656282db59e25be96"&gt;
&lt;img src="https://kamera25.github.io/godot_recipes/4.x/img/char_push_default.gif" alt="alt" class="lightbox-image" loading="lazy"&gt;
&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In some cases, this might be all you need. However, if you want to be able to push the bodies, you&amp;rsquo;ll need to make some changes.&lt;/p&gt;</description></item><item><title>Using 2D Joints</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/joints_2d/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/joints_2d/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;d like to understand Godot&amp;rsquo;s &lt;code&gt;Joint2D&lt;/code&gt; nodes.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Joint are used to constrain the movement of attached physics objects. For any joint node, you need to attach two bodies, which must extend from &lt;code&gt;PhysicsObject2D&lt;/code&gt;.&lt;/p&gt;
&lt;h4 id="properties"&gt;Properties&lt;/h4&gt;
&lt;p&gt;These properties are common to all joint nodes:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;Node A&lt;/em&gt; and &lt;em&gt;Node B&lt;/em&gt;: The assigned physics bodies.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Bias&lt;/em&gt;: The rate at which the joint pulls the two bodies back together if they move apart. Defaults to &lt;code&gt;0&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;&lt;em&gt;Disable Collisions&lt;/em&gt;: Allows the connected bodies to ignore collisions between them. Defaults to &lt;code&gt;true&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There are three types of &lt;i class="gd-Joint2D"&gt;&lt;/i&gt;&lt;code&gt;Joint2D&lt;/code&gt;. In all of the following examples, there is one &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; connected via a joint to a &lt;i class="gd-StaticBody2D"&gt;&lt;/i&gt;&lt;code&gt;StaticBody2D&lt;/code&gt;. &amp;ldquo;Visible Collision Shapes&amp;rdquo; is enabled in the screen images below so you can see a representation of the joint.&lt;/p&gt;</description></item><item><title>Conveyor Belt</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/conveyor_belt/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/conveyor_belt/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 to make a conveyor belt object that will move bodies (kinematic or rigid).&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;You can make a conveyor belt object using nothing but a &lt;i class="gd-StaticBody2D"&gt;&lt;/i&gt;&lt;code&gt;StaticBody2D&lt;/code&gt; by using its &lt;code&gt;constant_linear_velocity&lt;/code&gt; property.&lt;/p&gt;
&lt;div class="box notices cstyle note"&gt;
&lt;div class="box-label"&gt;&lt;i class="fa-fw fas fa-exclamation-circle"&gt;&lt;/i&gt; Note&lt;/div&gt;
&lt;div class="box-content"&gt;
&lt;p&gt;See &lt;a href="#3d"&gt;below&lt;/a&gt; for how to address this in 3D.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here&amp;rsquo;s an example, using a &lt;i class="gd-StaticBody2D"&gt;&lt;/i&gt;&lt;code&gt;StaticBody2D&lt;/code&gt; and a &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt;. No code was added. The static body&amp;rsquo;s &lt;em&gt;Constant Linear Velocity&lt;/em&gt; is set to &lt;code&gt;(200, 0)&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>Asteroids-style Physics (using RigidBody2D)</title><link>https://kamera25.github.io/godot_recipes/4.x/physics/asteroids_physics/index.html</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://kamera25.github.io/godot_recipes/4.x/physics/asteroids_physics/index.html</guid><description>&lt;h2 id="problem"&gt;Problem&lt;/h2&gt;
&lt;p&gt;You want to use a &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; to create a semi-realistic spaceship, a la &lt;em&gt;Asteroids&lt;/em&gt;.&lt;/p&gt;
&lt;h2 id="solution"&gt;Solution&lt;/h2&gt;
&lt;p&gt;Using &lt;i class="gd-RigidBody2D"&gt;&lt;/i&gt;&lt;code&gt;RigidBody2D&lt;/code&gt; can be tricky. Because it&amp;rsquo;s controlled by Godot&amp;rsquo;s physics engine, you need to apply forces rather than moving it directly. Before doing anything with rigid bodies, I highly recommend looking at the &lt;a href="https://docs.godotengine.org/en/stable/classes/class_rigidbody2d.html" target="_blank"&gt;RigidBody2D API doc&lt;/a&gt;, and we&amp;rsquo;ll refer to it as we work through this example.&lt;/p&gt;
&lt;p&gt;For this example, we&amp;rsquo;ll use the following node setup:&lt;/p&gt;</description></item></channel></rss>