Have I been calculating centripetal force wrong?

game:GetService("RunService").Heartbeat:Connect(function(deltatime)
	local v = script.Parent.AssemblyLinearVelocity.Magnitude
	local centripetalforce = (v^2)*script.Parent.BodyAngularVelocity.AngularVelocity.Y*(script.Parent.Mass)*1
	--	/(4/(math.cos((math.pi/2)-script.Parent.BodyAngularVelocity.AngularVelocity.Y)))
	
	local vel = script.Parent.CFrame:VectorToObjectSpace(script.Parent.AssemblyLinearVelocity)
	if script.Parent.AssemblyLinearVelocity.Magnitude <100 then
		--script.Parent.VectorForce.Force = Vector3.new(centripetalforce,0,script.Parent.Mass*100)
		script.Parent.VectorForce.Force = (script.Parent.CFrame.RightVector*centripetalforce)+(script.Parent.CFrame.LookVector*script.Parent.Mass*10)

	else
		--script.Parent.VectorForce.Force = Vector3.new(centripetalforce,0,0)-(vel*script.Parent.Mass*10)
	
		script.Parent.VectorForce.Force = (script.Parent.CFrame.RightVector*centripetalforce)-(script.Parent.AssemblyLinearVelocity*script.Parent.Mass*10)
	end
end)

so basically the centripetal force becomes too strong at high speeds.

The equation for centripetal force is f = (mv^2)/r
It looks like you have v^2 and m but I don’t think you need the angular velocity, and you will need to divide by r, the radius of the circle that script.Parent is traveling in.

I don’t think it’s relevant anyways since the force still would be too high.

Sounds like @FroggoBLOX’ advice is solid with regards to the physics. Just chiming in on other parts of your code -

  • You should be using RunService.Stepped here, not Heartbeat. Be sure to change your function parameters to function (time, deltatime).
  • You should use variables more liberally in your code.
    • Long lines of script.Parent.Blah.Blah.Blah makes things hard to read/debug.
    • Ideally, each input to your physics equation is represented by a variable to make things crystal clear.
    • It can make your code more performant as there is a higher cost for stuff like script.Parent.VectorForce.Force = ... rather than just vf.Force = ...
1 Like

Look, this code was not for “game” purposes, it was an experiment. I literally need help with the “physics” side of things.