Tutorial
<p dir="auto"><img src="https://images.hive.blog/768x0/https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/DQmeRXYK5hTURHD9TqUuGi4vPsockATFzcKFZdawUYpq24B_1680x8400" srcset="https://images.hive.blog/768x0/https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/DQmeRXYK5hTURHD9TqUuGi4vPsockATFzcKFZdawUYpq24B_1680x8400 1x, https://images.hive.blog/1536x0/https://steemit-production-imageproxy-thumbnail.s3.amazonaws.com/DQmeRXYK5hTURHD9TqUuGi4vPsockATFzcKFZdawUYpq24B_1680x8400 2x" /> ...learn about RigidBody Chains!
<h1>What Will I Learn?
<p dir="auto">Hi,
<p dir="auto">In my last <a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-verlet-chain-v0-01" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">tutorial, I demonstrated how to create a simulated Chain, using Verlet Integration; i.e. implemented without using the Godot built-in physics engine.
<p dir="auto">In true fairness, I've written this as the counterpart to it.
<blockquote>
<p dir="auto">... and boy, how much better it is!
<p dir="auto">This is what we end up with:
<p dir="auto"><center><br />
<img src="https://images.hive.blog/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521662409/bphyjchcv2ots0dsivct.gif" alt="rigidbody chains.gif" /><br />
<br />
<center>Note: the recording method uses 30fps; therefore, it breaks the quality of all gifs!
<hr />
<h3>Assumptions
<blockquote>
<ul>
<li>You have installed <a href="https://steemit.com/gamedev/@sp33dy/installing-godot-engine-v3-0-windows" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Godot Engine v3.0
<li>You are familiar with GDScipt
<h3>You will
<ul>
<li>Overview
<li>Create a Loop as RigidBody2D
<li>Anchor the Loop
<li>Link the Loops together and Anchor them
<li>Chain Script to build the full chain
<li>Rotate the Links
<li>Add a Ball to interact with the Chain
<h1>Requirements
<p dir="auto">You must have installed <a href="https://steemit.com/gamedev/@sp33dy/installing-godot-engine-v3-0-windows" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Godot Engine v3.0.
<p dir="auto">All the code from this tutorial is provided in a <a href="https://github.com/sp33dy/Godot-v3-Tutorials-Competent" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub repository. I'll explain more about this, towards the end of the tutorial. You may want to download this
<hr />
<h1>Overview
<p dir="auto">We are going to use the out-of-the-box 2D physics Nodes that Godot supplies. In particular:
<ul>
<li><p dir="auto">RigidBody2D : I think of these as independent living and breathing entities that obey all configured Physical properties
<li><p dir="auto">StaticBody2D : These are objects that are fixed, such as Anchors, Floors, Walls, etc
<li><p dir="auto">KinematicBody2D : These are the user/player type Nodes that live in the physical world, but are instructed to move by user input. They will obey certain Physics rules when configured and will collide!
<li><p dir="auto">PinJoint2D : This is the mechanism for connecting two Physics Nodes together, so that one affects the other, through a 'pinned' position; i.e. we are going connect one 'Loop' to the next, so that the child may wrap around the parent.
<p dir="auto">We will also configure the environment to ensure Gravity and other important factors are applied to our world.
<p dir="auto">Believe me, this is VERY simple and easy to apply, this should take you no more than a few minutes to complete!
<h1>Create a Loop as a Rigid Body
<p dir="auto">Let's start by creating our Main actor, the Loop. I'm going to stick to the analogy that I made-up in the previous article:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663072/uwu7bwmopwogcglc5n8g.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663072/uwu7bwmopwogcglc5n8g.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663072/uwu7bwmopwogcglc5n8g.png 2x" />
<p dir="auto">We are going to create the Loop as a RigidBody because we want it to obey the laws of physics and NOT be controlled by us (the user).
<blockquote>
<p dir="auto"><em>NOTE: I saved my Loop scene in a folder hierarchy of /Chain/Loop/Loop.tscn
<p dir="auto">Create a new Scene and add a RigidBody2D to the root node:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663199/ni9uejg39ygq7iy3hqpy.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663199/ni9uejg39ygq7iy3hqpy.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663199/ni9uejg39ygq7iy3hqpy.png 2x" />
<p dir="auto">As you can see, I would like you to also add a CollisionShape2D (we've used these in previous tutorials) and a Sprite.
<p dir="auto">Ensure you create the CollisionShape2D as a CircleShape2D and set its radius to 12 (which is half of the 24 pixels of the Loop PNG image file):
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663340/djscxrjopomlt5xuxwiv.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663340/djscxrjopomlt5xuxwiv.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663340/djscxrjopomlt5xuxwiv.png 2x" />
<p dir="auto">Add the Loop image <img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670266/kl7auqihm0z0fhybjprg.png" alt="Loop.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670266/kl7auqihm0z0fhybjprg.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670266/kl7auqihm0z0fhybjprg.png 2x" /> to the Sprite texture:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663361/pm5kpuavagb0grxcqpdy.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663361/pm5kpuavagb0grxcqpdy.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663361/pm5kpuavagb0grxcqpdy.png 2x" />
<p dir="auto">We are done, it's that easy! Try adding an Instance of the Loop to a new Game Scene and run it!
<p dir="auto"><center><br />
<img src="https://images.hive.blog/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521663644/tzxlbh6y33yohsf7206t.gif" alt="Loop dropping.gif" /><br />
<p dir="auto">... oops, it doesn't do a lot, other than fall off the screen!
<h1>Anchor the Loop
<p dir="auto">Let's Anchor the Loop to the ceiling. To do this, we need to use a StaticBody2D, as they generally don't move!
<p dir="auto">Create a new Chain Scene by forming the following structure:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664002/tdpyzkymm44wnh4ndoer.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664002/tdpyzkymm44wnh4ndoer.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664002/tdpyzkymm44wnh4ndoer.png 2x" />
<ol>
<li>The Root node is a Node2D object because we need to place the chain where ever we like on the screen
<li>The Anchor is the StaticBody2D Node, added as a child to keep it separate from the 'Chain' (this would allow us to lift it and its two children into a separate instance if we needed/wanted)
<li>Give the Anchor a CollisionShape2D, which will be a CircleShape2D of 12 radius
<li>A Sprite with the Anchor image <img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670442/vqtzlr85srxeoyfptiiz.png" alt="Anchor.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670442/vqtzlr85srxeoyfptiiz.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521670442/vqtzlr85srxeoyfptiiz.png 2x" /> is then added (this is a child to the CollisionShape2D, but could be a child of the root) <img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664220/szofhcirhrmhwpqdpcjx.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664220/szofhcirhrmhwpqdpcjx.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664220/szofhcirhrmhwpqdpcjx.png 2x" />
<blockquote>
<p dir="auto">Let's ignore the script that I have (as seen in the hierarchy screenshot) for now.
<p dir="auto">Save the Chain (I placed into /Chain/Chain.tscn) and then add it to your Game Scene.
<p dir="auto">Try running!
<p dir="auto"><center><br />
<img src="https://images.hive.blog/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664517/enwv23k9ddprtg8bq7cq.gif" alt="anchor and dropping loop.gif" /><br />
<p dir="auto">As you'll observe, the Chain Anchor remains onscreen, but the Loop goes falling away!
<h1>Link the Loops together and Anchor them
<p dir="auto">We need to Link the Loops together and eventually hang them off the Anchor Node.
<p dir="auto">This is achieved by another hierarchy, please create a new Scene called Link (I saved in /Chain/Link/Link.tscn):
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664723/ppwlurlgef9mmrbwkabs.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664723/ppwlurlgef9mmrbwkabs.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664723/ppwlurlgef9mmrbwkabs.png 2x" />
<ol>
<li>The root node is a PinJoint2D, its purpose is to link two Nodes together and ensure their movement are orchestrated.
<p dir="auto">The following PinJoint2D properties need to be configured:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664903/q2emshcia8d8gqvaeg2h.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664903/q2emshcia8d8gqvaeg2h.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664903/q2emshcia8d8gqvaeg2h.png 2x" />
<ul>
<li>Softness : should be set to 0.1, which dictates how the two Nodes bond together. This value was picked as it stops the formed chain from shaking (play with this value when up and running!)
<li>Bias : should be set to 0.9, which instructs the Nodes to pull together as quickly as possible (we want to maintain them touching)
<li>Disable Collision : ensure this is false, which means Collision Detection is ON between Loops (in my opinion, this is a bad double negative in the tool!)
<ol>
<li>The Link sprite texture is added to the image <img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664802/jxnrghvd97pfwfxsd0ft.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664802/jxnrghvd97pfwfxsd0ft.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521664802/jxnrghvd97pfwfxsd0ft.png 2x" />. Make sure the Z Index of this Sprite is higher than the Loop Sprite, otherwise it will look wrong when it appears under the loop!
<p dir="auto">I'm going to ignore the Script that is associated with the Sprite for now. I will return to it.
<p dir="auto">We now have the Link, but it does NOTHING on its own. It has to be configured with two Nodes that are pinned. To do this, I'm going to revert back to the Chain Scene and add the script I ignored earlier.
<h1>Chain Script to build the full chain
<p dir="auto">Open the Chain Scene, add a Script to the Root Node2D Chain Node:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665226/jstp0pwq1qxyencqsxfa.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665226/jstp0pwq1qxyencqsxfa.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665226/jstp0pwq1qxyencqsxfa.png 2x" />
<p dir="auto">The following script should be added:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665260/fgl6wkzfinoddc90isxw.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665260/fgl6wkzfinoddc90isxw.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521665260/fgl6wkzfinoddc90isxw.png 2x" />
<p dir="auto">Let's walk through the code:
<pre><code>extends Node2D
const LOOP = preload("res://Chain/Loop/Loop.tscn")
const LINK = preload("res://Chain/Link/Link.tscn")
export (int) var loops = 1
<blockquote>
<p dir="auto">The Node2D class is extended
<blockquote>
<p dir="auto">Two constants are defined, which preload the Loop and Link Scenes, ready to be instanced
<blockquote>
<p dir="auto">An integer is exposed to the Tool, allowing the number of Loops in the chain to be set
<pre><code>func _ready():
var parent = $Anchor
for i in range (loops):
var child = addLoop(parent)
addLink(parent, child)
parent = child
<blockquote>
<p dir="auto">When the Node is <em>ready, the chain is created.
<blockquote>
<p dir="auto">First, a variable known as a parent is set with the child Anchor Node in the hierarchy; thus, this will hold the chain up!
<blockquote>
<p dir="auto">Loop for the number of Loops set in the editor
<blockquote>
<p dir="auto">Next add a Loop and retain a reference to the Node (as a child)
<blockquote>
<p dir="auto">Create a Link, using the known parent and child Nodes
<blockquote>
<p dir="auto">Finally, set the parent to the new child; as it will become the parent to the next loop!
<pre><code>func addLoop(parent):
var loop = LOOP.instance()
loop.position = parent.position
loop.position.y += 26
add_child(loop)
return loop
<blockquote>
<p dir="auto">The <em>addLoop function does what it says on the tin
<blockquote>
<p dir="auto">A new instance of the Loop Scene is created
<blockquote>
<p dir="auto">The position of the Loop is set to the parents' position plus 26 pixels down
<blockquote>
<p dir="auto">Before returning the Loop Node to the caller, it is added as a child to the Chain Node
<pre><code>func addLink(parent, child):
var pin = LINK.instance()
pin.node_a = parent.get_path()
pin.node_b = child.get_path()
parent.add_child(pin)
<blockquote>
<p dir="auto">The <em>addLink function creates the instance of the Link Node
<blockquote>
<p dir="auto">The parent and child are set as node a & b of the pin joint
<blockquote>
<p dir="auto">Finally the pin is added to the parent, which is important! By adding the pin to the parent, its offset will be the middle of the parent loop; thus, any rotation occurs around the outside of the loop, which is what we want!
<p dir="auto">Return to your Game Scene and remove any Loop Nodes that you added, i.e. you should only have a single Chain Node added; for which you'll want to set the loop count:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668171/acdm6hmfdmujdktn2nsn.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668171/acdm6hmfdmujdktn2nsn.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668171/acdm6hmfdmujdktn2nsn.png 2x" />
<p dir="auto">Set this to any number you like! Rerun the Game:
<p dir="auto"><center><br />
<img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669133/sszkhbha17xu4nivdllb.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669133/sszkhbha17xu4nivdllb.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669133/sszkhbha17xu4nivdllb.png 2x" /><br />
<p dir="auto">...Ah. The chain is semi-formed, the link doesn't show correctly!
<h1>Rotate the Links
<p dir="auto">We need the Link Sprites to update themselves and rotate to the angle between the parent and child nodes. Fortunately, this is accomplished by adding a Script (I mentioned it above) to the Link Sprite:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669232/utxvpjiwwfhzutn7iouu.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669232/utxvpjiwwfhzutn7iouu.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669232/utxvpjiwwfhzutn7iouu.png 2x" />
<p dir="auto">The Script being:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669435/vbxhxatzf9bssdzlbojg.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669435/vbxhxatzf9bssdzlbojg.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669435/vbxhxatzf9bssdzlbojg.png 2x" />
<pre><code>extends Sprite
onready var nodeA = getNode("node_a")
onready var nodeB = getNode("node_b")
<blockquote>
<p dir="auto">Extend the Sprite class and set two variables to the parent and child nodes when ready; they use the following helper function
<pre><code>func getNode(name):
return get_parent().get_node(get_parent()[name])
<blockquote>
<p dir="auto">A helper function which retrieves a named node from the pin joint and returns the full node for the node path
<pre><code>func _physics_process(delta):
global_rotation = nodeB.position.angle_to_point(nodeA.position)
<blockquote>
<p dir="auto">After each Physics update (rather than process frame), change the rotation of the link to the angle between the two nodes
<p dir="auto">Rerun and our Links become fixed:
<p dir="auto"><center><br />
<img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669556/lp5wovefihnzrugfml9j.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669556/lp5wovefihnzrugfml9j.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669556/lp5wovefihnzrugfml9j.png 2x" /><br />
<p dir="auto">... although, we do not have a way to interact with it!
<h1>Add a Ball to interact with the Chain
<p dir="auto">To interact, we need a KinematicBody2D as a shape of a Ball. You can probably figure this out for yourself now! However, here are the details:
<p dir="auto"><img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668449/affsqmgb4vr2aop9ywcx.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668449/affsqmgb4vr2aop9ywcx.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668449/affsqmgb4vr2aop9ywcx.png 2x" />
<ol>
<li>Add a KinematicNode2D and call it Ball. I'll provide the script below
<li>Add a CollisionShape2D with a CircleShape2D and configure it with a 12 radius
<li>Add a Sprite with a 24 x 24 Ball PNG <img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668558/upphfiwefytslqgzlr3y.png" alt="Ball.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668558/upphfiwefytslqgzlr3y.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668558/upphfiwefytslqgzlr3y.png 2x" />
<li>Add a Control, for which I explained in the previous tutorial! Wire its Inspector>Node><em>mouse_entered() and <em>mouse_exited() functions to the Ball Node Script
<p dir="auto">The Script being:<br />
<img src="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668655/glcmh3iibo0ummxyt11m.png" alt="image.png" srcset="https://images.hive.blog/768x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668655/glcmh3iibo0ummxyt11m.png 1x, https://images.hive.blog/1536x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521668655/glcmh3iibo0ummxyt11m.png 2x" />
<pre><code>extends KinematicBody2D
var over = false
<blockquote>
<p dir="auto">Extend the KinematicBody2D class and define a variable to represent if the mouse is over the ball
<pre><code>func _process(delta):
if Input.is_mouse_button_pressed(BUTTON_LEFT) and over:
var mousePos = get_viewport().get_mouse_position()
position += mousePos - global_position
<blockquote>
<p dir="auto">Per frame, check whether the mouse is pressed and it is over the Ball. If so, calculate and move the Ball to the new Vector
<pre><code>func _on_Control_mouse_entered():
over = true
modulate = Color(0x0000ffff)
<blockquote>
<p dir="auto">The Control <em>mouse_entered() function is wired to this, which sets the <em>over flag to true to indicate the mouse is over the Ball and change its colour to highlight the fact
<pre><code>func _on_Control_mouse_exited():
over = false
modulate = Color(0xffffffff)
<blockquote>
<p dir="auto">The <em>mouse_exited() function of the Control is wired to this, which resets the flag to indicate the Mouse has left the Ball and reset the colour back to default
<p dir="auto">Add the Ball as an instance to the Game Scene and rerun:
<p dir="auto"><center><br />
<img src="https://images.hive.blog/0x0/https://res.cloudinary.com/hpiynhbhq/image/upload/v1521669708/fo5oeeufsa0rjyguzbuy.gif" alt="ball interaction.gif" /><br />
<p dir="auto">... we can now interact with the Chain!! Mission accomplished.
<p dir="auto">Try adding more Balls and Chains to see how they work together!
<p dir="auto">Open up the ProjectSettings and look at the Physics settings. Try turning off gravity or changing it's direction!
<p dir="auto">Have a play with the PinJoint2D and the RigidBody settings, such as Mass and Weight etc.
<p dir="auto">With these options, you can make a very heavy or light chain for example!
<h1>Finally
<p dir="auto">This tutorial has shown you how to implement a RigidBody Chain! To be honest, it is far superior to the <a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-verlet-chain-v0-01" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Verlet Chain in every way:
<ul>
<li>It deals with Loop to Loop collisions
<li>Is hardware accelerated
<li>Is simple in construction
<li>Will interact with other Physic Objects!
<p dir="auto">I can see many improvements to make it. To retro-fit, these into the Verlet implementation would be a waste of effort, unless I need it in a future game!
<p dir="auto">I will use this to form a 'rope' and a 'rickety bridge', but you have the basics here to do it yourself!
<p dir="auto">Please do comment and ask questions! I'm more than happy to interact with you.
<h1>Sample Project
<p dir="auto">I hope you've read through this Tutorial, as it will provide you with the hands-on skills that you simply can not learn from downloading the sample set of code.
<p dir="auto">However, for those wanting the code, please download from <a href="https://github.com/sp33dy/Godot-v3-Tutorials-Competent" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">GitHub.
<p dir="auto">You should then Import the "RigidBody Chain Swing" folder into Godot Engine.
<h1>Other Tutorials
<h4>Beginners
<blockquote>
<ul>
<li><a href="https://steemit.com/gamedev/@sp33dy/installing-godot-engine-v3-0-windows" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Install Godot Engine 3.0
<li><a href="https://steemit.com/gamedev/@sp33dy/first-demo-godot-engine-v3-0" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Installing your First Demo
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-your-first-moving-sprite" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Your first Sprite!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-move-your-sprite" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Move your first Sprite!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-create-lots-of-sprites" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Create lots of Sprites!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-sprite-formations" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Sprite formations!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-smooth-movement#comments" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Smooth Movement!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-invader-graphics" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Invader Graphics!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-player-ship" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Player Ship!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-bullets" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Bullets
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-collision-dectection" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Collision Detection!
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-colour-use" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Colour use!
<h4>Competent
<blockquote>
<ul>
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-custom-tilemap" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Custom TileMaps
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-custom-tilemap-scrolling" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Custom TileMap Scrolling
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-generic-screen-wrapping-sprite" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Screen Wrapping Sprite
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-generic-screen-wrapping-node" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Screen Wrap Node
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-physics-verlet-vs-rigidbody" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Verlet vs RigidBody Physics
<li><a href="https://steemit.com/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-verlet-chain-v0-01" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Verlet Chain!
<p dir="auto"><br /><hr /><em>Posted on <a href="https://utopian.io/utopian-io/@sp33dy/tutorial-godot-engine-v3-gdscript-rigidbody-chain" target="_blank" rel="noreferrer noopener" title="This link will take you away from hive.blog" class="external_link">Utopian.io - Rewarding Open Source Contributors<hr /><p>
I'm going to start providing YouTube videos, as I really dislike the quality of the GIFs:
Thank you for the contribution. It has been approved.
You can contact us on Discord.
[utopian-moderator]
click here.Congratulations @sp33dy, this post is the fifth most rewarded post (based on pending payouts) in the last 12 hours written by a User account holder (accounts that hold between 0.1 and 1.0 Mega Vests). The total number of posts by User account holders during this period was 2338 and the total pending payments to posts in this category was $5224.35. To see the full list of highest paid posts across all accounts categories,
If you do not wish to receive these messages in future, please reply stop to this comment.
Huh! Only 5th? I must try harder :(
Hey @sp33dy I am @utopian-io. I have just upvoted you!
Achievements
Community-Driven Witness!
I am the first and only Steem Community-Driven Witness. Participate on Discord. Lets GROW TOGETHER!
Up-vote this comment to grow my power and help Open Source contributions like this one. Want to chat? Join me on Discord https://discord.gg/Pc8HG9x
I've experimented here with the first image, which appears to be the one shown in the search lists. It looks a little odd in the article, but at least it provides a better preview! I will fix my approach with this in the future.
Nope, didn't like it, so removed and reverted back to the simple splash image.
Nice tutorial!
For me, programming is really hard to do but always try to improve my skills on it. I will also try to check platform that you mentioned in this article.
Do you have some advice for a beginner? Maybe I should start at some point?
Thanks for this post, hope that you will share more tutorials like that with us. Keep doing :)
Hi, if you check my profile https://steemit.com/utopian-io/@sp33dy, I've provided lots of different tutorials, market Beginner, Competent and Expert. There's one that shows you how to install Godot (which is really quite simple and FAST). There's another that shows you how to get one of the sample 3D games up and running. Then there's a bunch that have gradually been building a 'Space Invaders' clone. What you are looking at here is a 'Competent' developer, i.e. one that knows their way around the GUI (which you would quickly learn from the others I mention). The advice I have is, get it installed and try it! Seriously, it won't take you long.
Hey @sp33dy
This was an interesting read. Been messing around with Godot for a couple of months. Haven't really messed with the actual physics engine. This makes me want to. Then again its fun to make your own "fake" physics.
Also, Just got started on steemit. Do you recomend anyone else in gamedev to follow?
Hi Wolfwin, I've only been around these parts for the past month and a half, so the answer to your question is, no I really don't. There are LOTS of posts coming in all the time and I've been adding lots of people that I've enjoyed reading, but it as varied from 'silver coin collecting', through 'graphics design, to 'motorbike venture across Europe' and ends up with the usual crypto articles!
There doesn't appear to be a lot here for Godot, which is a shame, but the search is a good start.
Coming back to subject, I'm still convinced doing your own "fake" physics (aka the Verlet tutorial I wrote) can be better when your game doesn't need the fully fledged physics engine; i.e. if you are trying to create a simple "Space Invaders", why deal with the invaders as rigid bodies? Yes, it can be done, but occasionaly, I find my machine gets a 'bit' stuttery. If that happened whilst I'm trying to kill marauding aliens, I'd get really angry!
Yeah, move_and_slide() and move_and_collide() can do most of the heavy lifting.
GDQuest, on youtube, has great Godot tutorials. You may want to check him out!
Ah yes, I'd started to stumble on a lot of his stuff.