Daw588
(Daw588)
February 27, 2023, 3:14am
#1
My motorcycle goes crazy when I turn too sharply, I tried adjusting all the PID module parameters but none of them fixed my issue.
local PID = require(ReplicatedStorage.PID)
local BalancePID = PID.new(-3000, 3000, 100, 80, 0)
local function update(deltaTime: number)
local tilt = root.Orientation.Z
local force = BalancePID:Calculate(deltaTime, 0, tilt)
root.BalanceForce.Force = Vector3.zAxis * force
end
RunService.Heartbeat:Connect(update)
5uphi
(5uphi)
February 27, 2023, 10:53am
#2
You can also use a AlignOrientation
With these settings
take note of the Mode, AlignType and PrimaryAxis
and then you can use the CFrame property to tilt the bike
1 Like
Daw588
(Daw588)
February 27, 2023, 12:58pm
#3
Can you clarify how I am suppose to tilt the motorcycle with the CFrame
property of AlignOrientation
?
You don’t have to, the AlignOrientation
instance already helps you does that. Also, there is no CFrame
property in it.
Daw588
(Daw588)
February 27, 2023, 1:11pm
#5
There is, take a look at the documentation .
I followed @5uphi ’s instructions and it is not working.
Can I see your current code? if that helps.
Daw588
(Daw588)
February 27, 2023, 1:16pm
#7
There is no code for AlignOrientation though. If you are talking about the PID, it’s on my original post.
I don’t think AlignOrientation
instance would work in such instance. So, I believe we should be sticking to PID, though I never heard what is this thing.
I see, I am not a geek in using that, so I can’t really help you much…
5uphi
(5uphi)
February 27, 2023, 2:26pm
#11
here is a demo that uses AlignOrientation
Motorcycle.rbxl (42.7 KB)
and this is the script I used to tilt the motorcycle
local runService = game:GetService("RunService")
local model = script.Parent
local tiltAmount = 1
runService.Heartbeat:Connect(function(deltaTime)
local rightVector = model.Part.CFrame.LookVector:Cross(Vector3.yAxis) * (model.VehicleSeat.SteerFloat * tiltAmount)
model.AlignOrientation.PrimaryAxis = (Vector3.yAxis + rightVector).Unit
end)
if you want to control more then one axis then you would need to set PrimaryAxisOnly to false and then use CFrame to rotate
but in the demo I have PrimaryAxisOnly set to true so i use AlignOrientation.PrimaryAxis
to set the angle
4 Likes
system
(system)
Closed
March 13, 2023, 2:27pm
#12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.