How can I stop a hinge constraint from "snapping back" to default position when disabled?

Im thinking… maybe put in a third hinge, a ball hinge, that leaves the head swiveling free so when the other hinges stop that the head wont snap back?? Just thinking out loud

Keep in mind when you switch to another axis, it has to snap to that axis… the only way i can think of it not doing this is using that asset i linked you to for the turret that enables the head to move wherever your mouse points. In essence your bot will move like a tank does and the head will move around like its turret gun.

I was playing around with it when another solution hit me. What if I just rotate the attachments on one hinge constraint so that I only need one hinge then? Then the hinge will be able to move in both axis without too much extra stuff.

1 Like

Try it out… can you script the rotation?

Yeah, I can just change the orientation of both the attachments. I haven’t scripted it yet but I’m testing it out in Play mode and it seems to be working. I’ll script it and show the results, if it works out.

1 Like

Alright, so that didn’t really work. It just made the head rotate all over the place and still snap back when I changed rotation directions. I don’t really know what to do, and I don’t want to make it follow the mouse.

Hmmmm, have you tried instead of disabling one hinge when you want to control another just dropping its force to zero instead?

Yeah, but as soon as I give it it’s force back, it snaps back to it’s TargetAngle 0 position, since the other hinge has no force to keep it at the same angle. Basically same thing happens as the original issue.

Is the movement purely for visual sake? Maybe you can tween the movement and always have it return to center before it begins the next tween movement?

The rotation is for analyzing the surface and rocks and other things on the planet. The head holds the ChemCam laser, so the head has to rotate horizontally and vertically to be able to aim/focus on certain areas.

I see, so tween wont work then for that purpose.

How about just using a ball hinge, no limits or such, and using cframe to move the head to the desired direction? That way it will stay in that position until u move it again.

That would require the welds’ CFrames being changed, won’t it? Since the head is made up of several meshes welded together.

I dont believe so… they have weld constraints right?

You might have to weld constraint an inner block inside the head and control that block.

Here’s how it’s set up right now:
image
All parts have the qCFrameWeldThingy other than those two you see in the screenshot (Meshes/11 and Meshes/8). The weld constraint just keeps Meshes/11 welded to Meshes/8 because for some reason it won’t get welded like the other parts. The hinge constraint is the only thing keeping the head connected to the boom/“neck”. If I disable or remove the hinge then the head falls off.

I removed the second hinge for now (which is why it isn’t in the screenshot) and have the head only rotate vertically so I can continue scripting the rest of it, but the 2nd hinge was in Meshes/11 and also attached to an attachment on the same part of the neck as the 1st hinge’s neck attachment, except rotated sideways for the horizontal rotation.

Sorry if that was confusing to read, lol. Tried to make it as easy as I could.

Wait, why are you deleting the hinge for anything?

I think it’s due to fact that you’ve got 2 hinges working on 2 items, but in different orientations. Imagine this in real life, neither would work because both are fighting each other for the rotation.

Are you just using 2 attachments for both hinges? That won’t work since the alignment of the hinge depends on the Rotation of the Attachments.
Have you tried putting a HIngeConstraint from the main arm to a secondary Part, then put another hinge from the secondary Part to the Head? Both the Attachments in the Secondary Part can be at the same location, just with Rotations 90 degrees to each other so it’s acting on 3 Parts instead of 2 (MeshParts).
I’ve used multiple cases of having 2 hinges operating together in various Servo, Motor, and None modes and haven’t seen anything like this before. I never have 2 Parts with 2 hinges trying to compete against each other though.

2 Likes

Oh, and as mentioned earlier, Universal joints will flex in both directions, but you can’t control them.
Before they came out I made one for a visible universal joint under the middle of my front end loader Construction Site. Most control bugs fixed! - Roblox which consisted of the 2 drive shafts with hinge constraints at the universal joint end and had the Attachments 90 degrees to each other. I then put the center joint in as a sphere with 2 Attachments in it that were 90 degrees to each other.
Connected the shafts to the sphere, it works perfectly. When you drive forward or backward the driveshaft spins realistically even when the loader is turning left or right.

1 Like

@Scottifly the game isnt public anymore? Id love to check it out… oh or is it not open to mobile, im mobile right now.

And yes the hinge idea is excellent… attach hinge one to neck, then attach second hinge to the head so that it works independently of the neck hinge, i feel stupid for not thinking of this.

But you have to have a third Part between the head and neck.
Think of it like this, you want to attach 2 boards together and you need them to flex at a joint like you are using.
Screw one hinge to the bottom board. Screw the other hinge to the bottom board but 90 degrees to the first hinge.
Screw both hinges to the top board.
The 2 boards are now solidly attached to each other and can’t flex because each hinge is trying to bend but can’t since the other hinge is restricting it
You have to attach both hinges to another board.
The good thing about Roblox HInges is you can move the Attachments to wherever you like.

And yes, my construction site relies on keyboard input so you can’t play on mobile.

Awesome thanks! I got it working now with your help, but it bounces a lot whenever it hits it’s target angle. Is there any way I can stop it from doing that, and smoothly rotate to it’s target angle and stop when it gets there? Or at least reduce the bouncing?

Is the bouncing from something colliding?

No, everything in the head is CanCollide false. It’s just the hinges being whacky. I’ve seen a lot of people have issues with them.