Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why doesn't BodyForce using cosine oscillate a part back and forth elastically?

Asked by 6 years ago

I am trying to use Body Force to move a part in a circular orbit, however, all my part currently does is move in a sinusoidal motion in the Z direction. It is as if there is a "drag" on the part which stops the force in the particular direction being great enough to oscillate it between the diameter of the circle.

I am using F = mrw^2, where Fx = mw^2*rcos(theta) and Fz = mw^2rsin(theta) (In the code below, I am just trying to make it perpetually oscillate in the x axis from a radius of 1)

Part = script.Parent
BodyForce = Instance.new("BodyForce",Part)
Mass = Part:GetMass()
Orbit = Instance.new("BoolValue",Part)
Orbit.Name = "Orbit"
Orbit.Value = true
AVelocity = 1
Radius = 1

function OrbitPart()
    BodyForce.Force = Vector3.new(BodyForce.Force.X,workspace.Gravity*Mass,BodyForce.Force.Z)
    repeat
        local theta = 0
        for theta = 0,360 do
            BodyForce.Force = Vector3.new(Mass*(AVelocity^2)*Radius*math.cos(math.rad(theta)),BodyForce.Force.Y,0)
            wait()
        end
    until Orbit.Value == false
end

OrbitPart()

Help would be much appreciated to get on the right tracks to make the part oscillate correctly, I don't know what I'm doing incorrectly for the part to not oscillate elastically. Thanks.

Answer this question