I’m making a creator mode for a game called ‘Find The Boi’ (a puzzle game that isn’t fully done tbh), and I have a an instance-moving function that uses mouse.Hit.Position but it’s jittery and sometimes moves parts unintentionally
Here’s some footage of what’s happening:
here’s the function for moving a part
function ControlBuilder.PositionInstance(director: BasePart)
if not selectedTarget then return end
local dirData = directions[director.Name]
if not dirData then return end
-- setting up the director's position directly :p
local mousePos = mouse.Hit.Position
local basePos = director.Position
local targetPos = Vector3.new(
if dirData.sideAxis == "X" then mousePos.X else director.Position.X,
if dirData.sideAxis == "Y" then mousePos.Y else director.Position.Y,
if dirData.sideAxis == "Z" then mousePos.Z else director.Position.Z
)
director.Position = targetPos
-- calculating offset of other directors and the selected instance
local offsetAmount = (selectedTarget.Size[dirData.sideAxis] / 2) + OFFSET_FROM_OBJECT
local newSelectedPos = director.Position - (dirData.vector * offsetAmount)
selectedTarget.Position = newSelectedPos
for _, child in selectedTarget:GetChildren() do
if child:IsA("BasePart") and child:GetAttribute("IsPositioner") and child ~= director then
local childDirData = directions[child.Name]
if not childDirData then continue end
local childOffset = childDirData.vector * ((selectedTarget.Size[childDirData.sideAxis] / 2) + OFFSET_FROM_OBJECT)
child.Position = selectedTarget.Position + childOffset
end
end
end
dirData stores the vector to move to and the sideAxis as a string
For example: a “Top” director has dirData = {vector = Vector3.new(0,1,0), sideAxis = "Y"})
This function is called when the player holds on one of the sides using UserInputService (via InputBegan and InputEnded). It gets looped through RenderStepped until the player releases the said side
I have tried using raycasting before, but I feel that it’s inefficient for this system, and it barely works. I might’ve set it up incorrectly though.
Are there any ways I can reduce jitter and accidental drags? Thanks ![]()
→ I’m not that active here so I might respond late