KeepsMomentum on motors

I can already see myself not explaining very well but I’ll try my best


In this little pic the green block has a motor ontop that spins the red at TopParamB speed of 1.5 watch until the end and I type in 0. This should mean that the motor on the green block is no longer spinning the red block but for some reason the red block will instantly stop and lose all of it’s momentum which isn’t what I want.

I was hoping we could get a Boolan value here called something like KeepsMomentum and when true if I did what I just did (had the red block spinning and set the green block that was spinning it to 0) it would gradually lose momentum on it’s own until it came to a stop.

Motor surfaces create RotateV joints, which are only supposed to control velocity. You want to apply a torque as opposed to a constant angular velocity, so constrain the top part with a hinge surface/Rotate joint or Glue and create torsion by using two offset BodyThrusts.

If you still want to use motors, use both a RotateV and Hinge and set the RotateV’s Part0 to nil when you want it to stop spinning. This will conserve angular momentum.

1 Like

You lost me but yes I do want to use motors but how to do the second thing you said? The more detail and breakdown, the better. This is probably why this simple ‘KeepsMomentum’ feature is helpful because I don’t think an average kid is going to know how to do any of that.

You can make it gradually slow down with some Lua:

local RunService = game:GetService("RunService")

function SlowDownMotor(MotorPart,FromP,ToP,Duration)
	for i=0,1,1/(Duration/0.02) do
		local CalcNum = FromP * (1-i) + ToP * i
		MotorPart.TopParamB = CalcNum
		RunService.Stepped:wait()
	end
	MotorPart.TopParamB = ToP
end
SlowDownMotor(script.Parent,script.Parent.TopParamB,0,8)
2 Likes

Neat! Although it slowed down rather quickly, how would I edit this to make it slow down, slower?

Change the last perameter of the function call where it says “2”. 2 is the time it takes to slow down. So it’d take at least 2 seconds to reach the desired number.

1 Like
  1. Create a RotateV object and a Rotate object.
  2. Give them the same Part0, Part1, C0, and C1.
  3. Use the BackSurfaceInput of Part0 to change the RotateV’s velocity.
  4. When you want it to slow down, RotateV.Part1 = nil will stop applying torque to the part.

In code, that’s

local rel = CFrame.new(0, 15, 0)
local part0, part1 = workspace.Part0, workspace.Part1

local rotate = Instance.new('Rotate', part0)
local rotatev = Instance.new('RotateV', part0)

rotate.Name, rotatev.Name = 'Rotate', 'RotateV'
rotate.Part0, rotatev.Part0 = part0, part0
rotate.Part1, rotatev.Part1 = part1, part1
rotate.C0, rotatev.C0 = rel, rel
rotate.C1, rotatev.C1 = CFrame.new(), CFrame.new()

wait(5)
rotatev.Part1 = nil -- Stop applying torque to part1
wait(5)
rotatev.Part1 = part1 -- Start applying torque again to part1

Result:

http://gfycat.com/SpectacularUniformBushsqueaker

If you end up doing that, update it in Stepped so it plays nicely with physics.

1 Like

Thanks for the replies guys, it helped me to get the same effect near-enough although it was very confusing more so @ScrapYard 's post but I finally was able to understand it. Although, I don’t think i’ll remember it and it felt like a lot to do for something very simple.

So I’d still like to put forward the ‘KeepsMomentum’ idea or something like it. I can easily see a lot of kids getting very confused/frustrated with something like this.

I may be completely wrong, but…
can’t you just turn the surface to a Hinge instead of a Motor?

(idk)

First thing I tried but sadly no, it acts like a motor is still rotating it

Did you disable the motor properties, though?

Do you mean change this back to NoInput? That just stopped it straight away.

May not be what you want to do, but enabling the PhysicalProperties mode and changing the friction to ~0.02 on both parts may have a better effect when using Hinges.