I believe this is the issue. It keeps the steering input to -1. No change either as it is all ran inside a loop.
Below is the math that calculates the ai to move either left or right and towards the target.
Its self explanatory so I don’t think I will need to explain the works exactly.
I have done the liberty and given you the outputs of each print you see before you which will be in the form of comments on the right of each invoke.
ignore the timestamps as they all execute seemingly at the same time.
I am not the best with math. Please excuse me.
local angleY, angleX, angleZ = seat.CFrame:ToEulerAnglesYXZ() -- get the angles
local desiredAngle = math.deg(rot) - angleY + 90 -- do math
print(desiredAngle) -- 20:49:06.605 -43.945911908380424 - Studio
print(math.deg(rot) - angleY + 90) -- same as above quite literally
if desiredAngle > 180 then
desiredAngle = desiredAngle - 360
elseif desiredAngle < -180 then
desiredAngle = desiredAngle + 360
end
local steeringInput = math.clamp(desiredAngle / 90, -1, 1)
print(steeringInput) -- 20:49:06.605 -0.48828791009311584 - Studio
local throttleInput = 1
if (bumper.WorldPosition - target).Magnitude < 10 then
throttleInput = 0
end
Inputs:SetAttribute("steeringInput", steeringInput)
Inputs:SetAttribute("throttleInput", throttleInput)
It seems like the logic expects desiredAngle to be larger, or more aligned. In that case, you probably don’t want math.deg(rot) because rot is already in degrees. You can simplify this calculation to just remove the math.deg conversion. Make sure rot and angleY are using the same unit. If needed, you can try to adjust the angle offsets to make the steering input more responsive.