#draggable part help: alignPosition issue when moving and jumping sideways simultaneously

1 messages · Page 1 of 1 (latest)

azure shard
#

Hello! i'm currently having an issue. i have a part in which I can click and drag and it will follow the direction the user is facing (basically the cursor) while in first person. this is done by having an attachment in the humanoid root part with an offset so that the attachment is always in front of the player. an attachment and alignPosition is also created within the part that will be moved. the alignPosition aligns the part's attachment with the user's attachment and the user's attachment follows the cursor when actively holding the part.

this mechanic works perfectly, however when moving sideways and jumping at the same time (like to the right for example, remember while in first person) the part's attachment gets launched towards the player's direction, despite the user's attachment not getting launched. it seems like the player's physics is affecting the physics of the attachment/alignPosition. is there any way to fix this?

I've tried enabling rigidityEnabled, making it fix the issue, but it isn't desired due to its lack of smoothness when dragging and the ability to phase thru parts. I've also attached the player's attachment outside of the humanoidRootPart to see if the hrp's physics will no longer affect the attachment and thus the draggable part, however this doesn't fix the issue. I have attached a video, a studio file with the draggable part, and the script. thanks!

#

server scripts:

local Players = game:GetService("Players")

local offset = Vector3.new(0, 0, -8)

Players.PlayerAdded:Connect(function(player)
    player.CharacterAppearanceLoaded:Connect(function(character)
        local humanoidRootPart = character:FindFirstChild("HumanoidRootPart")
        
        if humanoidRootPart then
            local attachment = Instance.new("Attachment")
            attachment.Name = "LookAttachment"
            attachment.Parent = humanoidRootPart
            attachment.CFrame = CFrame.new(offset)
        end
    end)
end)

second server script:

local function drag(object)
    local detector = object:FindFirstChild("DragDetector")
    
    local posAttachment = Instance.new("Attachment")
    posAttachment.Parent = object
    
    local alignPos = Instance.new("AlignPosition")
    alignPos.Parent = object
    alignPos.Attachment0 = posAttachment
    alignPos.Enabled = false
    alignPos.Responsiveness = 30
    
    detector.DragStart:Connect(function(player)
        local attachment = getLookAttachment(player)
        if attachment then
            alignPos.Attachment1 = attachment
            alignPos.Enabled = true
        end
    end)
    
    detector.DragContinue:Connect(function(player, curRay, viewFrame)
        local attachment = getLookAttachment(player)
        if attachment then
            local y = viewFrame.LookVector.Y
            attachment.CFrame = CFrame.new(Vector3.new(0, (y * 8) + 1.5, -8))
        end
    end)
    
    detector.DragEnd:Connect(function()
        alignPos.Enabled = false
        alignPos.Attachment1 = nil
    end)
end
quiet pendant
#

not related but this looks tuff

#

lumber tycoon ahh