Hey guys, so for some reason my bike moves weirdly. Like when moves according to worldspace not local orientation. My goal is to move the bike towards the front
Note I have to use Right Vector due to the way i sized my Body part
https://gyazo.com/d79ae705be47b073dec39f296498279b.mp4 - Straight
https://gyazo.com/16bae2d44f2c44acb527cde40462bbf9.mp4 - Weird
Code:
local timeForSpeedUpAndSlowDown = .5 --Seconds
local seat = script.Parent.VehicleSeat
local FWheel = script.Parent.FWheel
local body = script.Parent.Body
local LinearVelocity = Instance.new("LinearVelocity", body)
local attachment = Instance.new("Attachment", body)
local attachmentAngle = Instance.new("Attachment", body)
LinearVelocity.RelativeTo = Enum.ActuatorRelativeTo.Attachment0
LinearVelocity.Attachment0 = attachment
local Gyro = Instance.new("BodyGyro", body)
Gyro.MaxTorque = Vector3.new(1,1,1) * 100000
Gyro.CFrame = body.CFrame
local CF = FWheel.Weld.C1
while wait() do
LinearVelocity.VectorVelocity = Gyro.CFrame.RightVector * (seat.Throttle * -100)
LinearVelocity.MaxForce = (body.AssemblyMass * LinearVelocity.VectorVelocity.Magnitude) / timeForSpeedUpAndSlowDown
Gyro.CFrame = body.CFrame * CFrame.Angles(0,seat.Steer * -math.rad(10),0)
FWheel.Weld.C1 = CF * CFrame.Angles(0,seat.Steer * math.rad(10),0)
end