How do I fix this wheel steering bug?

Hello World!

I came into a problem yesterday about these wheels only rotating depending on the world’s rotation. Can anyone please help?

Video :

Code :

if wheel.Name == "FL" then
	wheel.Orientation += Vector3.new(0, steerAngle, 0)
end
							
if wheel.Name == "FR" then
	wheel.Orientation += Vector3.new(0, steerAngle, 0)
end

Thanks in Advance!

1 Like

Does anyone know the solution for this?

Now I look at it, what are the wheels connected by?

They are connected by Welds using scripts.

In that case, connect it through hinge and set the Cframe on them, and not on the wheels.

Let me try it really quick. Just a sec.

Here’s the documentation

I don’t really wanna add attachments to my wheels or parts. I just need to know how to change the rotation of the front wheels of the car relative to it’s current rotation. Thanks though.

Conveniently, but only this is used for vehicles, mine also use it, and your inning can’t work well. Hingeconstaint does the calculation of rotation of the wheels perfectly.

Sadly, I’m making a raycast vehicle, but yeah, that’s the problem of this.

Do you mind if I send you the game file?

I’m on my mobile, but the wheels aren’t just like ornaments in raycast vehicles?

In this version, the wheels calculate the friction of the car.

--// Friction

							local steeringDir = wheel.CFrame.RightVector

							local tireVelocity = mainPart:GetVelocityAtPosition(wheel.Position)
							local steeringVelocity = steeringDir:Dot(tireVelocity)

							local tireMass = wheel:GetMass()

							local velChange = -steeringVelocity * friction

							local frictionForce = steeringDir * tireMass * velChange

							mainPart:ApplyImpulseAtPosition(frictionForce, wheel.Position)

Nvm I just fixed it lol. I just used the old welds lol.

New script.

if wheel.Name == "FL" then
							for _, v in pairs(mainPart:GetChildren()) do
								if v.Name == wheel.Name then
									v.C0 = CFrame.new(v.C0.Position) * CFrame.Angles(0, math.rad(steerAngle), 0)
								end
							end
						end

						if wheel.Name == "FR" then
							for _, v in pairs(mainPart:GetChildren()) do
								if v.Name == wheel.Name then
									v.C0 = CFrame.new(v.C0.Position) * CFrame.Angles(0, math.rad(steerAngle), 0)
								end
							end
						end

Actually I used Motor6d’s instead

I don’t know exactly how to do it, but I can look at it late. I used only physics for my cars and the wheels are connected to the hinge and even accordingly it spins. (I don’t mean old cars, they are very similar to raycast cars)

Alright, I fixed it though lol don’t worry. I just used Motor6d’s instead and used a new script.

if wheel.Name == "FL" then
							for _, v in pairs(mainPart:GetChildren()) do
								if v.Name == wheel.Name then
									v.C0 = CFrame.new(v.C0.Position) * CFrame.Angles(0, math.rad(wheelAngle), 0)
								end
							end
						end

						if wheel.Name == "FR" then
							for _, v in pairs(mainPart:GetChildren()) do
								if v.Name == wheel.Name then
									v.C0 = CFrame.new(v.C0.Position) * CFrame.Angles(0, math.rad(wheelAngle), 0)
								end
							end
						end
1 Like

These are the calculations about i told :rofl:

1 Like