function Engine.Update(Z)local H=Z.Main.CFrame local S=Z.Main.Velocity local w=H.lookVector local e=H.upVector local N=H.rightVector local j=math.abs(S:Dot(w))local K=Z.PitchInput local V=Z.YawInput local m=1 local X=EngineRate(m+minThrottle*(1-m))Z.speed=Z.Main.Velocity.magnitude if Z.BoostInput==-1 then return end MotorSound.Volume=X^.33333333333333*.4 MotorSound.PlaybackSpeed=X pitchFx.Octave=1/(X<.0001 and.0001 or X)local J=Z.BoostInput==1 and Z._BOOSTSPEED or Z.BoostInput==0 and Z._SPEED or 0 Z.Thruster.Velocity=(H.lookVector*(J*X))*v3(1,.8,1)Z.Steering.CFrame=cf(v3null,H.lookVector)*(EulerXYZ(0,V*Z._YAW,0)*EulerXYZ(Z._PITCH*K,0,V*Z._ROLL))Z.Steering.MaxTorque=v3(25,25*abs(e.y),25)*(j/J)^2 Z.Steering.P=3000*Clamp((j/J)^2/2+.5,0,1)Z.Thruster.MaxForce=v3(100000,math.huge,100000)end
-- Update engine forces base on control input
function Engine:Update()
	local c = self.Main.CFrame
	local vel = self.Main.Velocity

	local bz = c.lookVector
	local by = c.upVector
	local bx = c.rightVector
	local speed = math.abs(vel:Dot(bz))

	local stick_pitch = self.PitchInput
	local stick_yaw = self.YawInput

	local throttle = 1
	local rev = EngineRate(throttle + minThrottle * (1 - throttle))

	self.speed = self.Main.Velocity.magnitude

	if self.BoostInput == -1 then
		return
	end

	MotorSound.Volume = rev ^ (1 / 3) * 0.4
	MotorSound.PlaybackSpeed = rev
	pitchFx.Octave = 1 / (rev < 1e-4 and 1e-4 or rev)

	local targetSpeed = ((self.BoostInput == 1 and self._BOOSTSPEED) or (self.BoostInput == 0 and self._SPEED) or 0)
	self.Thruster.Velocity = c.lookVector * (targetSpeed * rev) * v3(1, 0.8, 1)
	self.Steering.CFrame = cf(v3null, c.lookVector)
		* (EulerXYZ(0, stick_yaw * self._YAW, 0) * EulerXYZ(self._PITCH * stick_pitch, 0, stick_yaw * self._ROLL))
	self.Steering.MaxTorque = v3(25, 25 * abs(by.y), 25) * (speed / targetSpeed) ^ 2
	self.Steering.P = 3000 * Clamp((speed / targetSpeed) ^ 2 / 2 + 0.5, 0, 1)
	self.Thruster.MaxForce = v3(100000, math.huge, 100000)
end -- Engine:Update()
