Physics revolute joint

GameMaker Studio developers

Physics revolute joint

In this section we will show you the Physics revolute joint feature. Discover how to join objects with attributes, these can represent a gear, a revolution engine or a simple rotary joint that is part of a bridge …

SoloStudio Tech Youtube Channel


1.0 – Creating a physical object

Before starting with the meetings, you must know the physical properties of our object and how to activate these. So let’s start …

The first thing to do is enter the physical mode, by pressing the virtual PHYSICS MODE button located on our main panel. Next we will press on the PHYSICS PROPS virtual button to display the physical settings of our object.

The selected object does not contain physical, we must add these attributes by clicking on the ADD PHYSICS virtual button.

Adding physical properties

From this moment we can adjust the different values that make up a physical object, the list of functionalities is as follows:

  • SHAPE TYPE: Assigns the type of collision our object will have:
    • CHAIN: Create a polygon-based collision that we created. It is called chain type because it only generates a few lines from our vectors, but lacking mass. It is widely used for static terrain, although later we will see that this type of collision can help us a lot. If we assign this type and we have not created any polygon for our object, the editor generates a box based on the size of the image.
    • CIRCLE: Creates a spherical collision for our object. The images that fit with this type of collision can perfectly be the wheels of a car, a gear, a ball, etc …
    • POLYGON: Create a collision from a polygon we have created. Unlike the CHAIN type, this type contains mass generated by the triangles that make up its area. Likewise, if our object does not contain any vertex data, a collision box will be assigned based on its image.
  • DENSITY: Adjust the density of our object. This serves to measure how the forces applied to this object will act. At higher density, more weight and resistance to forces. But this does not mean that your simulation is accelerated, this value directly affects the behavior when interacting with the environment.
  • RESTITUTION: Restitution affects the behavior of our object by colliding with any other physical object. Define the elasticity of the dough, as an example we could put a falling ball. The higher this number, the greater the rebound capacity when falling on a surface.
  • GROUP: Defines to which group our physical object belongs for their interaction. If the value is 0, our object will ignore any value assigned in other objects, having to define in a collision event with whom it can interact. On the other hand, if the value is any other number, as long as it matches the group value of another object, they interact with each other. When we want interaction between objects that are in different groups or in groups of negative value (-1), we must make use of the collision event.
  • LINEAR DAMP: This value defines the resistance to the forces. The higher the value, the greater resistance you will get to the forces around you. We will notice this resistance when falling from precipices, to the amount of force that we should apply to move an object and even when accelerating a rotating motor …
  • ANGULAR DAMP: This value defines the angular resistance. When an object rotates, it tends to slow its rotation because of the forces that make up our world. By adjusting this value we define how much resistance we apply to rotations.
  • FRCITION: This value defines the friction that an object will have when in contact with another surface. If we brake a wheel, our car does not stop instantly, since it generates a friction that causes the wheel to skid. The same happens here and if we adjust a high value, our object will brake dry, while a low one makes this slide.
  • AWAKE: Defines whether our object will be active at the beginning of the simulation in our physical world (value 1 / true), or otherwise inactive (0 / false), being present, but exempt from being part of the simulation until another object collides with the.
  • IS SENSOR: This Boolean value (1/0, true / false) determines if our object is a sensor. If so, our physical object is present in the simulation, but it is not affected by the forces that compose it. However, if collisions with this one are detected, this value can be used to create a switch that executes code in the GameMaker Studio collision event.
  • IS KINEMATIC: This value deactivates the interaction with other forces such as gravity, but allows us to move our object on stage. As an example, it can be very useful for creating a platform with a defined function, such as an elevator that does not take care of gravity.
  • FIXED ROTATION: By activating this variable our object is locked as far as rotational movements are concerned, acquiring as fixed value the angle that we have inserted in our editor.
  • JOINT TYPE: From here we select the type of joint that joins two objects. We will talk about the types of meetings in the following articles. This tutorial is based on the Revolute board.
  • ACTIVE: Our object will be completely canceled from the simulation until the opposite is decided. However, our object is still active on stage, being able to access it.
  • SHAPE SCALE: This value defines the scale of our collision form, in this same tutorial and a few paragraphs below we explain this function. It will be very useful to simulate different types of behaviors in our objects, depending on the mass they have.
Adjusting the physical properties

1.1 – The different types of shapes

Let’s configure the shape of two objects for physical simulation. The one on the left has a rectangle assigned as a collision, and as we see in the image below, the one on the right is assigned a spherical shape.

Creating different shapes

If we press PLAY on our stage we can do physical tests. If we press the F6 key on our keyboard, the tool accurately draws the collisions and the type of collision our objects have. Apart, we also show its center of mass, accompanied by two lines that represent the X (red) and Y (blue) axes.

If our object has a density of zero, if it is not of the CHAIN type as the ground below, its collision will be green, informing that it does not attend to gravity or forces.

Doing a simulation test

Knowing this, we will assign a density of 1 to these objects …

Adding density to our objects

As we see in the image below, our objects with physical properties come to life. These are part of the simulation and interaction with those present.

Simulation test with different shapes

If we scale an object that contains physics, its collision will also be adjusted to fit the new size of the object in question.

Scaling shape properties

In the image below you can see these objects with the scale changed …

Testing with scaled objects

If our object contains the creation of a polygon, when assigning physical properties, it will take as reference the polygon to create the collision. By pressing the virtual PHYSICS PROPS button we can adjust whether our polygon will be a vector chain or instead it will contain mass.

Creating a polygon

If we enter the “Polygon” option in the SHAPE TYPE value, our object will have mass. Being possible its total interaction with the world.

It should be noted that if our polygon is concave, Darkspine will section our polygon to make it compatible with our physics system.

Simulating a polygon with mass

On the other hand, if we introduce the “Chain” option, we will create collisions based on their vectors. Recall that this method is more efficient and suitable for static objects in our world, since they do not contain mass.

Can we add mass to this type of collision? Yes, in the example of this article we will observe that process.

Generating a polygon without mass

1.2 – Creating a joint

Let’s create an object that contains the image of a pattern that represents a bridge …

Selecting a texture

Configure an open polygon for this example, click on EDGE TEXTURE and assign the image …

Assigning a pattern to a model

We can adjust our model to the center of mass of our object with the vertices modification options (MODIFY VERTEX).

Modifying vectors

We duplicate this object and then proceed to configure the physical parameters for each one.

In the first object we will simply add physics without touching any parameters, giving us a density of 0 and being this static in our world.

For the second object we will give a density of 1 and assign a type of joint as shown in the image itself. By clicking on the JOINT TYPE virtual button we change the type of joint we want to insert, in this case a Revolute joint.

Assigning a type of joint

From this moment we can make use of the joint configuration, located in our main panel and called SET JOINT.

Clicking on the joint settings

DarkSpine invites us to select which object is part of our board, it will only be enough to CLICK LEFT on the first object and we will have consolidated the union (represented by a red line between the two objects).

Assigning the joint destination

If we press CLICK LEFT again and keep this pressed, we can see that a blue dot chases our cursor. This point adjusts the position of the board relative to our world. In this case we have placed it on the left surface of our object to create a joint that connects with your partner in the indicated coordinate.

Changing the coordinates of our joint

Now if we press PLAY we can start the simulation and see how the object with assigned density rotates relative to the position of the board.

Doing a joint test

1.3 – Duplicating a joint

Well, now we have decided to duplicate this object a few dozen times to create a chain of joints between them. For this we have activated the mesh by pressing on the virtual GRID button of our main panel. Because in this way we will have the exact precision to place our objects in the same coordinate and without difficulty.

Duplicating and positioning objects

When we duplicate a joint, it has the information of the entity to which it connects, therefore, our copies point to the first object as a reference. But it is not what we want. So we can press the virtual SET JOINT TARGET button to change the second identity, selecting the object we have on our left side to identify it as part of our joint.

Changing our joint target

This is our first result, a set of objects that have their collision configured as Chain, but which in turn has created a block of mass per object. Why does this happen? Well, if an object contains data from a meeting and it does not contain mass in the form of a collision, DarkSpine creates sensory blocks, which do not interact with our player but which do give a mass value. This together with the other pieces form the structure of a bridge.

Joint test

1.4 – Graphic settings

In the image below we appreciate that our bridge, but has defects, since each object draws its image independently. Therefore, when they rotate, graphic defects are observed that break the experience.

Physics test

In this case we have decided that with the help of logic, by assigning an object that contains a simple script, we can make a parent object draw the content of its children.

Creating a hierarchy

We have called this object OBJ_PHYSICS_BRIDGE and it is in charge of joining all the models and drawing them in real time depending on the position of your children.

Assigning logic to the parent object

Now our bridge looks splendid without graphic issues and completely interactive for the player.

Drawing our bridge

1.5 – Scaling the mass of a joint

We have talked about those boxes that are generated to give mass, the bigger these are, the heavier and solid our bridge will be. When we want to achieve the behavior of a trampoline, either because we have another type of image, we are allowed to configure these collision boxes by adjusting the SHAPE SCALE value in the PHYSICS PROPS panel. In our case we set the box to 0.5, thus subtracting 50% of its mass.

Adjusting the mass of our joint

Here you can see the result and the difference in size with the other blocks.

Testing the mass configuration

We do the same with the other objects and do a test. To visualize the behavior, it is highly recommended that you watch the header video.

Doing an elasticity test

1.6 – Duplicating a family

How could it be otherwise, DarkSpine allows duplication of a family that contains together, and in this case, the replica re-configures the settings to assign to its new binding partner. We won’t have to do anything else, so for one level, you won’t have to repeat a configuration process to add several bridges in a scenario.

Duplicating a family

1.7 – Scaling our family

We are allowed to scale our family, all the data of this will be adjusted relative to its new size.

Scaling a family of objects

These are the results of a duplicate and scaled bridge …

Test of a scaled bridge

1.8 – Rotating a family

In the same way we are allowed to rotate relative to the father our family. All joint adjustments will take this transformation into account to readjust their joints.

Rotating our hierarchy

In the image below we observe why this tool will be very useful.

Test of a rotated bridge

Recommendation:

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.


With everything we have learned, we have reached the end of this tutorial! We will see in several articles all the functionalities. I hope you enjoyed reading. From here we send you our best regards and see you in the next article!

You may also like:

2 Responses

  1. Matemáticamenteincorrecta says:

    Mejor explicado imposible y encima en Español ,gracias James.

    • James says:

      Te agradecemos el comentario y estamos muy emocionados! Intentamos que nuestra extensión sea global, y que cualquier persona en el mundo pueda usarla. Nos satisface que nos corrobores que los tutoriales tengan buena compresión lectora, ponemos mucho énfasis en ello. Puedes consultarnos cualquier duda desde los comentarios o en el foro especializado para DarkSpine.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.