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

But there isn’t a way to do it without the snapping. I really want to eliminate the snapping back somehow because right now the whole purpose of it being able to rotate is kind of defeated if it can only do one axis.

No i meant you create an instance of the hinge constraint for vertical movement and when it needs to look horizontally, you destroy the instance of the vertical you created and create the horizontal. In the middle of those two, the head will always be centered but thats ok cuz robots look up or down then center before they look left and right ( well old school robots atleast lol).

Im just wondering how to script the instances because your robot moves location. That will be an area where the scripters can chime in, i know basics but not creating hinge instances on moving objects.

1 Like

If all else fails i guess you could also script a mouse pointer movement… like how they use on turret guns… it points to whereever your mouse moves.

After thinking a little about it, that makes much more sense now. Thanks so much, I think it might work! I’ll try it tomorrow morning. I appreciate your help! The old school robotic style would probably work best for right now. Maybe I’ll have a go at more complicated stuff when I have more experience and understand it more.

1 Like

To try it out… grab a working turret from the toolbox and use its mouse movement script and see how it works on your bot.

Here you go try this out it has an asset available with a demo of it used on a dummy:

1 Like

I’m sorry if I missed it, but do you have issues with CanCollide Parts hitting each other causing the head to snap back to center?
Also, hinges usually need quite a bit of Force, try upping it from 5000 to 1000000 to see if that makes a difference.

1 Like

All the parts are cancollide false. I’ll try that tomorrow, the force change.

So I just spent some time trying this, but I still have the same problem. Whenever I delete the old hinge, it snaps back. I’ve tried rotating the attachments to the orientation of the head whenever the hinge finishes rotating, but it still doesn’t work.

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.