Hello! I am making a boat and it works pretty well, the only problem is when you turn sometimes it snaps the other way before turning. I am not too familiar with BodyGyros and if someone can help explain them and help me figure out why it snaps the other way when turning that would be great!
CODE:
--snippet of on key pressed
if input.KeyCode == Enum.KeyCode.A and boat.Seat.Occupant == player.Character.Humanoid and turning == false then
print("TURNING LEFT")
turning = true
turnL = Instance.new("BodyGyro",boat.Body)
turnL.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
while turning == true do
wait()
turnL.CFrame = CFrame.Angles(0,math.rad(boat.Body.Orientation.Y + 10),0)
end
end
if input.KeyCode == Enum.KeyCode.D and boat.Seat.Occupant == player.Character.Humanoid and turning == false then
print("TURNING RIGHT")
turning = true
turnR = Instance.new("BodyGyro",boat.Body)
turnR.MaxTorque = Vector3.new(math.huge, math.huge, math.huge)
while turning == true do
wait()
turnR.CFrame = CFrame.Angles(0,math.rad(boat.Body.Orientation.Y + -10),0)
end
end
--snippet of on key released
if input.KeyCode == Enum.KeyCode.A and turnL and turning == true then
print("STOPPING LEFT")
turning = false
turnL:Destroy()
if boost then
boost.MaxForce = Vector3.new(0,0,0)
wait()
boost.MaxForce = Vector3.new(4000, 4000, 4000)
end
end
if input.KeyCode == Enum.KeyCode.D and turnR and turning == true then
print("STOPPING RIGHT")
turning = false
turnR:Destroy()
if boost then
boost.MaxForce = Vector3.new(0,0,0)
wait()
boost.MaxForce = Vector3.new(4000, 4000, 4000)
end
end
Here is a video of what i mean just incase you couldnt visualize it!
when i turn it rammed into the wall from the snapping im talking about