How To Make A Part Attached To A Hinge Stop Spinning

Right now I’m trying to make a minigun in my game where when the player clicks the barrel starts spinning and when they let go it slows down and stops.

The issue is that since the barrel is attached via a hinge it spins slightly even when the gun is not activated.

I’ve tried using limits enabled on the hinge after the barrel stops spinning but that just ended up slowly spinning the character.

How would I go about making the hinge stop completely after the barrel is done spinning?

1 Like

There are two ways you might want to go about this and you can choose which one, or both, if you would like, as they could both be used in conjunction.

The first option is to edit the Barrel’s “Custom Physical Properties” which you can find in a Part’s Properties. Setting the Part’s Density to a higher number makes the part harder to accelerate, and harder to keep in motion. If you apply a force to a denser object, it will slow down and stop completely much faster than a Part with a Low Density.

The second option is to just Anchor the part with a script when the part is supposed to stop spinning. This option is much more simple, but also loses some functionality for “slowly spinning to a stop”.

If I were you, I’d set the barrel’s density to be much higher, and adjust the forces accordingly, so that it can reach the required spinning speed, and then slow down at an acceptable rate. Then, when it has mostly slowed down, you can anchor the part using a script that detects when the player has let go of the mouse button, holding the barrel locked in place.

I should have made this more clear. I’m using a hinge with a motor to accelerate the barrel when the tool is activated and deccelerate the barrel when the tool is deactivated. So I have the accelerating and deccelerating done.

Now I have just managed to fix the barrel spinning after the tool is deactivated. All I did was set the MotorMaxTorque to 0. However, there’s now a new issue. When the player stands idle with the minigun equipped, they slowly rotate.

While it’s difficult to entirely decode the problem you’re having without having the actual thing in front of me, I may be able to figure something out. If you hold it and do NOT set the MotorMaxTorque to 0, does your character still spin? Because my next idea would be to create a Weld constraint between the barrel and the rest of the gun, that is naturally Enabled, but is De-enabled when the barrel is supposed to be spinning. Then you can avoid setting MaxMotorTorque to 0, hopefully removing the issue with your character spinning.

The welding thing did stop the character from spinning, however when the barrel is welded it snaps so that it’s oriented to the same orientation as the part it’s welded too.

Here’s the video:
Minigun Help.wmv (2.0 MB)

I think it slowly stopping would be a good effect, but if you do not want that effect I recommend messing with custom physical properties.