Physics rope joint
The physics Distance and Rope Joint are very useful for our game. You can create from simple ropes to a mesh of joints interactively.
1.0 – Distance joint
Let’s start by defining two objects with physical properties. One of them will have a density of 0, while the other will move freely with a density 1. Now we have to assign a distance joint from the physics panel, which allows us to create a rigid joint between these objects.
Placing ourselves in the SET JOINT panel, a menu is always displayed according to the type of board we have selected. In this case we have the option to adjust our union and if they can collide with each other.
1.1 – Adjusting coordinates
Once the coordinates are defined, we make a test to verify that our object effectively simulates being rigidly attached to a static block.
This type of joint can be adjusted from any point of our objects or scenarios, being able to create different mechanics for our game.
To observe the demonstration we will join the points from the opposite corners between blocks.
If the objects are family, when rotating our father, the points of union will be adjusted relative to the transformation of our objects.
In this way we do not lose the configuration of these …
1.3 – Joining multiple joints
We have not talked about this in previous articles, but the editor, as in GameMaker, allows joining different unions to create mechanisms. In the image below we create another joint between our pulleys and ropes.
This is not the best example of creating mechanisms, but by doing a test we will realize the possibilities that these functions allow us.
1.4 – Interaction with the environment
When we have the simulation active, we observe that a small block continuously follows our cursor. This object is always present and serves so that we can interact with the physical objects present on the stage. This interrupts the correct simulation of our world, but it helps us to test the mechanisms.
1.5 – The Rope joint
Let us now create a rope type joint (ROPE JOINT) with a duplicated object. The process is exactly the same as when we created a DISTANCE type. The difference between these two types of joint is that the second one has no stiffness, being able to adjust a new value called MAX LENGTH. This value is responsible for telling our board how much distance it can fall or stretch from its point of origin.
As we have said in the previous paragraph, the first type of joint is completely rigid. If we grab this, it travels from the assigned distance radius.
However, when we talk about the second type, it can be moved anywhere within its radius of length. With this we get the feeling of being in front of a rope tied to a block that can be malleable.
1.6 – Assigning distance values
We test this knowledge by defining how much distance our rope can travel, giving it a value of 200.
By executing the level we can see that 200 pixels have effectively fallen from its position, leaving it at a lower height than the first rigid type joint. If we connect the block with our mouse by clicking on it, we can more clearly appreciate what happens between the different types together.
1.7 – Chaining objects
We can also be able to join several objects with this type of joint and generate the real simulation of a rope.
Unfortunately, we currently do not have the right graphics to show a real representation of this simulation. We just want you to learn how simulation works and we are eager to see the game you can get, which is not a small thing.
To get an idea, the pattern to follow is the same as explained when we decided to create a bridge. If we join objects with particular graphics, it should not cost us to create what we imagine.
We strongly recommend that you view the video located at the beginning of this article to get a clear idea of this section.
The video tutorials provided on the YouTube channel support subtitle contributions from users. This means that any user can contribute to add subtitles with the editor and the new contribution program of YouTube subscribers.
We finish our article here, remember to review the previous types of meeting if you have not already done so. Since the first written entries on physics, we have provided important data on physics. It is advisable to read these articles if you have not already done so. From here we send you our best regards and see you in the next tutorial!