🔗LBJT: Weld Joint7️⃣.
LibGDX Box2d Joints Tutorials.
🔗LBJT: Weld Joint7️⃣.
LibGDX Box2d Joints Tutorials.

LBJT Application: Download for ease of study!

Weld Joint
Text separators are set using chatGPT.
This article is about the Weld Joint, its settings, and how to make it work.
To make it easier to understand what is happening and how to perform practical tasks, start with the article: **🔗LBJT: Сommon in Joints 1️⃣.**
And so the… Weld Joint
Weld joint — a joint intended for connecting 2 bodies together with the possibility of adjusting the elasticity and the rate of disappearance of oscillations. (usually used as welding 2 bodies together)
First, we need to set up the joint. For this, each joint has its own implementation of JointDef. You can read about this in the article: **🔗LBJT: Common in Joints 1️⃣. And now let’s talk about the WeldJointDef**.
WeldJointDef settings:
(Mandatory)
- bodyA — first joint body.
- bodyB — second joint body.
- collideConnected — <boolean> Specifies whether bodyA should collide with bodyB.
(Optional)
- localAnchorA — the local anchor point relative to bodyA origin.
- localAnchorB — the local anchor point relative to bodyB origin.
- referenceAngle — initial angle between bodyA and bodyB, (default 0 | measured in radians).
- frequencyHz — affects the elasticity of the joint between bodyA and bodyB.
Value < 1: With values less than 1, such as 0.5 or 0.7, the joint will be strongly stretched, resembling a soft spring.
Value > 1: With values greater than 1, such as 2, 5, or 10, the joint will stretch very little or not at all, similar to a stiff spring.
- dampingRatio — suppresses vibrations and takes values from 0 to 1.
0: does not suppress.
1: almost absolute suppression.

WeldJointDef settings
Practice. How to create a Weld Joint?
In order for you to be able to test Joints, you need to interact with bodies, for this you need to implement MouseJoint. How to implement it is described in article* 🔗LBJT: Mouse Joint 2️⃣.*
Our example will consist of a static circle (blue) and a dynamic circle (green) connected by WeldJoint.

Weld Joint
1️⃣Create 2 bodies: a static circle and a dynamic circle:
val staticCircle = StaticBody
val dynamicCircle = DynamicBody
2️⃣Create WeldJoint:
world.createJoint(WeldJointDef().apply {
bodyA = staticCircle
bodyB = dynamicCircle
collideConnected = false
}
Note that collideConnected = false, this is done so that the connected bodies do not touch each other.
That’s it, you can already run the program and the bodies will be connected, but there is one but, they will be connected at their anchor points, where the center of mass is specified, to fix this, you need to configure localAnchorA, localAnchorB about how I explained how to calculate anchor points in the article: **🔗LBJT: Сommon in Joints 1️⃣.**
3️⃣Configure: localAnchorA, localAnchorB:
world.createJoint(WeldJointDef().apply {
bodyA = staticCircle
bodyB = dynamicCircle
collideConnected = false
localAnchorA.set(Vector2(2.5f, 3.0f))
localAnchorB.set(Vector2(2.5f, 0.0f))
}
*Do not forget that the values are indicated in meters*. About the units of measurement of meters, kilograms, seconds (MKS) is written in the article:* **🔗LBJT: Сommon in Joints 1️⃣.*
4️⃣Configure: referenceAngle:
referenceAngle — just changes the angle between bodyA and bodyB.
Do not forget that all angles in Box2d are measured in radians.
Clockwise negative angles. Counter-clockwise are positive angles.

WeldJoint referenceAngle
world.createJoint(WeldJointDef().apply {
...
referenceAngle = 45f * DEGTORAD
}
5️⃣Configure: frequencyHz (elasticity):
By default, WeldJoint will connect 2 bodies and they will be like one body, if you want it to be like a spring between them and there are oscillations, then you need to adjust the frequencyHz.
world.createJoint(WeldJointDef().apply {
...
frequencyHz = 0.5f
}

WeldJoint frequenceHz
6️⃣Configure: dampingRatio:
dampingRatio — damps oscillations to the sides, so it can be said that it works together with the frequencyHz.
world.createJoint(WeldJointDef().apply {
...
frequencyHz = 0.5f
dampingRatio = 0.8f
}

WeldJoint dampingRatio
The body returns to its original position very smoothly and slowly, a good effect, the larger the value of dampingRatio, the slower the body will return to its original position (remember that this only works together with the frequencyHz).
It works and it’s great 😎.
[embed]
GitHub: https://github.com/Vladislav-Shesternin/LBJT 😺.
Download app LBJT ⬇️.
Main source of information 📘.
Go to Part 8️⃣.
PS. Vel_daN: Love what You DO 💚.
메타데이터
- post_id
- a18f733702bb
- slug
- lbjt-weld-joint7️⃣-a18f733702bb
- url
- https://medium.com/@veldan1202/lbjt-weld-joint7%EF%B8%8F%E2%83%A3-a18f733702bb
- canonical_url
- https://medium.com/@veldan1202/lbjt-weld-joint7%EF%B8%8F%E2%83%A3-a18f733702bb
- author_url
- https://medium.com/@veldan1202
- status
- ok
- fetched_at
- 2026-06-28 10:39:35