When I make something I usually use weldconstraint’s as it is just easier for me but I’m trying out Motor6D and have got myself stuck on something that I’m hoping someone can help me with!
I’m unsure if it is just a genuine Roblox Motor6D limitation or I’ve done something incredibly stupid.
I have this camera model that i’m trying to orientate based on mouse position using Motor6D, the camera is made up of 2 models in it - Tilt and Pan. The idea was that as I move my mouse left and right then both Pan and Tilt would go left and right and then as I move my mouse up and down then only the Tilt model would go up and down.
I have the Tilt’s Motor6D Part0 set as its parent’s (Pan) primarypart and then Part1 is its own primarypart so I figured Tilt would orientate with Pan or am I just being stupid?
Please help!
The server script:
local crane = script.Parent
local seat = workspace:FindFirstChild("CraneSeat")
local panMotor = crane.Pan.Motor6D
local tiltMotor = crane.Pan.Tilt.Motor6D
local replicatedStorage = game:GetService("ReplicatedStorage")
local movementEvent = replicatedStorage:WaitForChild("CraneMovementEvent")
local player = nil
local smoothness = 0.1
seat.Changed:Connect(function(property)
if property == "Occupant" then
if seat.Occupant then
player = game.Players:GetPlayerFromCharacter(seat.Occupant.Parent)
else
player = nil
end
end
end)
movementEvent.OnServerEvent:Connect(function(player, forwardMovement, yawMovement, panAngle, tiltAngle)
print("Received ForwardMovement:", forwardMovement)
print("Received YawMovement:", yawMovement)
print("Received PanAngle:", panAngle)
print("Received TiltAngle:", tiltAngle)
local panPrimaryPart = crane.Pan.PrimaryPart
local tiltPrimaryPart = crane.Pan.Tilt.PrimaryPart
if panPrimaryPart then
panPrimaryPart.CFrame = CFrame.new(panPrimaryPart.Position) * CFrame.Angles(0, math.rad(panAngle), 0)
end
if tiltPrimaryPart then
tiltPrimaryPart.CFrame = CFrame.new(tiltPrimaryPart.Position) * CFrame.Angles(math.rad(tiltAngle), 0, 0)
end
if panMotor then
panMotor.DesiredAngle = math.rad(panAngle)
end
if tiltMotor then
tiltMotor.DesiredAngle = math.rad(tiltAngle)
end
end)
Video of problem: