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.