Hi, I’m working on a vehicle chassis, but I’m having problems with the steering, I’m trying to steer the wheels by checking the VehicleSeat Input, and then adjusting the orientation of the Attachment to the wheel, to steer.
Here’s my code: (Doesnt work)
local steer = 30
while true do
if seat.SteerFloat == 1 then
AttachmentFL.Orientation = Vector3.new(0, steer, -90)
AttachmentFR.Orientation = Vector3.new(0, steer, -90)
end
if seat.SteerFloat == -1 then
AttachmentFL.Orientation = Vector3.new(0, -steer, -90)
AttachmentFR.Orientation = Vector3.new(0, -steer, -90)
end
if seat.SteerFloat == 0 then
AttachmentFL.Orientation = Vector3.new(0, 0, -90)
AttachmentFR.Orientation = Vector3.new(0, 0, -90)
end
wait()
end
You need to update on every frame after the user input update. Also, your code can be simplified to:
local STEER = 30
local function updateSteering()
local orientation = Vector3.new(0, STEER * seat.SteerFloat, -90)
AttachmentFL.Orientation = orientation
AttachmentFR.Orientation = orientation
end
I’m not getting any errors, Also I have already seen that video, and I’m trying to make a different/simplified chassis, and I can assure you I haven’t made any mistakes with my Attachments.
Also, if you look at my code, you can see its based off of that video…
Your code is very inefficient because you are using if statements to direct your steering.
Print some values and ensure they are corresponding correctly, also describe your issue more in depth.
I know, thats why I’m here (on the devforum) for help…
I’m trying to steer the wheels by checking the VehicleSeat Input, and then adjusting the orientation of the Attachment to the wheel by a certain amount of degrees, to make the wheel turn, thus, steering the vehicle…
You should not use a while true do loop. Also, I only simplified your code, so it is no guarantee that it would work. You should play around with the function and test what it does and why it does not work (you might have mixed up an axis for example).
I have done that many times, My attachments are in the correct position, I know that for a fact, because when I don’t use the If statements the steering and everything works (but the vehicle then is not being controlled by the Vehicle Seat)