Can't Align Motorcycle Fork With Wheel

I want to align my motorcycle fork with the wheel, like shown in the video. Currently, I am using a weld constraint to achieve that, which is causing the issue that the fork rotates with the wheel. I have tried using other constraints to solve this but didn’t get far. I tried doing it via script, but it didn’t work either.

I want to achieve the same effect shown, but without the fork rotating forward with the wheel.

The motorcycle was built using sleitnick’s car rig tutorial series with some slight modifications. (https://www.youtube.com/watch?v=qBn0KmiFfQQ&list=PLk3R4TM3pnqsoSq8HVgzcx49YS3V4depV)

This is the script being used on the motorcycle.

local physicsS = game:GetService("PhysicsService")
local runS = game:GetService("RunService")

local defaultG = "Default"
local characterG = "Character"

local motorcycle = script.Parent
local seat = motorcycle.VehicleSeat

local function CollideThing(character, canCollide)
	
	local group = canCollide and defaultG or characterG
	
	for i,v in ipairs(character:GetDescendants()) do
		
		if v:IsA("BasePart") then
			
			v.Massless = not canCollide
			v.CollisionGroup = group
			
		end
		
	end
	
end

local function OccupantChanged()
	
	if seat.Occupant then

		CollideThing(game.Workspace:FindFirstChild("Nudibriado"), false)
		
	end
	
	if not seat.Occupant then
		
		CollideThing(game.Workspace:FindFirstChild("Nudibriado") ,true)
		
	end
	
end

seat:GetPropertyChangedSignal("Occupant"):Connect(OccupantChanged)

local steer = 0
local throttle = 0

runS.Stepped:Connect(function()
	
	local steerGoal = -motorcycle.VehicleSeat.SteerFloat * 15
	steer = steer + (steerGoal - steer) * 0.05
	
	motorcycle.PhysicsModel.ForkPlatform.Orientation = Vector3.new(motorcycle.PhysicsModel.BodyPlatform.Orientation.X, motorcycle.PhysicsModel.BodyPlatform.Orientation.Y + steer, motorcycle.PhysicsModel.ForkPlatform.Orientation.Z)
	motorcycle.PhysicsModel.BodyPlatform.Attachment.Orientation = Vector3.new(0, 180, -steer)
	
	local throttleGoal = motorcycle.VehicleSeat.ThrottleFloat * motorcycle.VehicleSeat.MaxSpeed
	throttle = throttle + (throttleGoal - throttle) * 0.1

	motorcycle.PhysicsConstraints.BackCyl.MotorMaxTorque = motorcycle.VehicleSeat.Torque
	motorcycle.PhysicsConstraints.BackCyl.AngularVelocity = throttle

end)

Any help would be appreciated.

Are you welding the wheel to the fork?
Not sure what Sleitnick’s model uses for the wheel hinge but I’d think you should be using a HingeConstraint for the wheel so it rotates.

1 Like

Sorry, I had forgotten to show the physics part of the motorcycle.

I’m welding the fork to the wheel, there is a cylindrical and a rod constraint connected to the wheel and the front pink part.

I’m going to try to use a hinge constraint to see if it works, thanks for the tip.

Edit: It worked, thank you!

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.