Get the amount of stress on a WeldConstraint

  1. What do you want to achieve? Keep it simple and clear!

I want to make a bridge that breaks at the joints in which it has too much force. So, there will be a lot of parts connected by welds to each other, each weld being places where it can break. I want to have a server-side script that updates the amount of stress on any given joint and breaks (destroys) it if the stress is too much.

  1. What is the issue? Include screenshots / videos if possible!

I’m not sure of a way to fetch the current amount of stress on a weld at any given time. The way I’m doing it right now is: (with c being the weld constraint)

c.Part0.Mass * (c.Part0.Velocity.Magnitude^2)

However, that only works if the part0 is moving. Also, I don’t even know if that’s accurate at all, I just saw it somewhere.

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?

I looked through some other posts about adding a feature to get the stress on a weld, but they were just requesting that a feature be added.

I am doing a science project where you have to make a toothpick bridge, and I want to test different designs, but it takes too long in real life, so I want to do it here. This is how I want to go about this:

--this script (not local) is the child of a Part with a WeldConstraint attaching it to another part

local maxStress = 100 --idk test variable
local constraints = {}
--add all weldconstraints to the constraints table
for _, v in pairs(script.Parent:GetChildren()) do
	if v:IsA("WeldConstraint") then
		table.insert(constraints, v)
	end
end

function update()
     for _, c in pairs(constraints) do
          if c.stress >= maxStress
               c:Destroy()
          end
     end
end

while (true)
     wait(0.1)
     update()
end

So, how would I get the stress on a weld that isn’t moving?

4 Likes

Okay, this is a weird idea I had, but it could work.

Maybe, instead of using welds, you use align position to hold the bridge together. But each align position is relative to the part it comes from. Then you can adjust the strength of the align positions for the strength of the welds. Also, if a part gets to far away from where it’s supposed to be aligned to, you can destroy the align position, like you would destroy a weld under to much stress.

Here’s a example:


I know this is a sort of “wild” idea, but I think the only other way would be to recreate roblox’s physics engine, which would be hard.
You could also pair this with align orientation, so stuff doesn’t spin out of control. Along with that, maybe you could use a ball socket constraint with align orientation, or some other pair, to make the movement under stress more realistic.

If you find another way, you should probably go with that, since this is a bit of a weird way, but if you can’t find another way, maybe give this a try.

I hope this helps in some way to solve your problem!

So with your model, if I were to put the parts under a lot of weight, the align position would be kind of elastic and eventually break? Like, the align position isn’t welded in place and immovable, and it can break under some (small) amount of force? This seems very useful.

Yes, it would sort of be like attaching everything with rubber bands, and once the rubber bands stretch to long, they would break.
Also, the align position is constantly relative to the part it’s branching off from, so it moves with it’s that part.

By the way, align position is this constraint if you didn’t know:
https://create.roblox.com/docs/reference/engine/classes/AlignPosition

Also, maybe the align position should move the part based on it’s weld point, not the center:


This would be a better way to align them, compared to how I said in the first post.

Another idea for an improvement I had would be to maybe also make the align positions mutual (so with a pair of parts, both parts are aligning eachother), so when one part moves, it pulls on the other.

What about making the bridge with unanchored parts but in a way that it holds everything together and when it becomes to heavy it calopse

That would be the solution srtaub is suggesting.

That seems like it should work well! However, I don’t really have the time to test it since I am super busy with school and sports right now. I will try the moment I’m free!

2 Likes

So I tried it, and the alignPositions are really weak and they bend like a hinge. Is there any way to make them stronger?

Try increasing the MaxForce property:
https://create.roblox.com/docs/reference/engine/classes/AlignPosition#MaxForce

MaxForce is the maximum force align position can apply, so increasing it will allow it to apply more force to reach it’s goal.

It also may be worth taking a look at these properties too, since they can also change how align position reaches it’s goal:
https://create.roblox.com/docs/reference/engine/classes/AlignPosition#MaxVelocity
https://create.roblox.com/docs/reference/engine/classes/AlignPosition#Responsiveness

1 Like