This script is meant to constantly accelerate the part at the same rate, regardless of the direction or mass.
local Body = script.Parent
local Part = script.Parent.Parent
Part.Anchored = false
local LookVector = Part.CFrame.LookVector
local weight = Part:GetMass()*196.2 -- weight
local accel = 4 -- acceleration
local mass = Part:GetMass() -- mass
Body.MaxForce = Vector3.new((accel*LookVector.X)*mass, weight + (accel*LookVector.Y)*mass,(accel*LookVector.Z)*mass) -- resultant force
Body.Velocity = LookVector * 40
local count = 0
local timer = tick()
local PrevVelo = Part.Velocity.Magnitude
while true do
wait()
LookVector = Part.CFrame.LookVector
Body.Velocity = LookVector * 40
Body.MaxForce = Vector3.new((accel*LookVector.X)*mass, weight + (accel*LookVector.Y)*mass,(accel*LookVector.Z)*mass) -- resultant force
if tick() > timer + 1 then
timer = tick()
count = count + 1
print("Time: "..count.." Seconds")
print("Velocity: "..Part.Velocity.Magnitude.." m/s")
print("Acceleration: "..Part.Velocity.Magnitude - PrevVelo.." m/s²")
PrevVelo = Part.Velocity.Magnitude
print("------------------------------------------------------------------------------")
end
end
It works perfectly while lookvector stays the same, but if I start changing look vector with bodyangular velocity, everything goes out of control and the part eventually just moves in the same direction regardless of the lookvector. Anybody know how I can resolve this?