im trying to make a tool point to the mouse cursor, but if i try applying the cframe from the lookat function then multiplying it by the inverse of the origin its weirdly reversed
it talks about the use of changing the attachment of a rigid constraint in order to change the orientation of some part, but i dont think thats necessary as changing the grip offset i assume is basically doing the same thing for making the tool look in a direction so i repurposed the code for changing the attachments cframe to change the grip
code (its a local script within the handle of a tool)
local oar = script.Parent.Parent
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local arrow = workspace:WaitForChild("arrow")
task.wait(1)
local grip = player.Character["Right Arm"].RightGripAttachment
oar.Activated:Connect(function()
local cframe = CFrame.lookAt(grip.WorldPosition, mouse.Hit.Position)
oar.Grip = grip.WorldCFrame:Inverse() * cframe
arrow.CFrame = cframe
end)
i included an arrow which is just a part to show what the cframe of the lookat looks like and what the tool is supposed to look like
tool.Activated:Connect(function()
local from = grip.WorldPosition
local to = mouse.Hit.Position
local target = CFrame.lookAt(from, to)
tool.Grip = grip.WorldCFrame:ToObjectSpace(target)
end)
this doesnt seem to fix the problem since youre starting from the position of the attachment which is relative to the character and then using its cframe which is relative to the character, thanks for the reply though
maybe, the only thing ive done with motor6ds is just replacing them with ball constraints for a ragdoll. do you mind elaborating on this? like how i would go about it and how to get it to point in the direction of the mouse using motor6ds
The fact you’re just the opposite on that one value makes me think you’re really close. Maybe someone else will know for sure… I’m kind of speculating here, with nothing to work with.
Well you would basically put a moter6D into the player’s character every time it loads and then attach the moter6d part0 to a player torso or anything and then whenever a tool is equipped change the part1 to that tool and when its unequipped change back to nil. Etc etc. here are some links: Point a moter6D to a point - #3 by dthecoolest How to animate Tool Parts (Guns, Knifes etc.)
thanks for the links, im not entirely sure if this would change the results but considering people use it maybe its more reliable than grips, but i have a feeling the issue isn’t really at fault with the grips and its something just wrong with the inverse of the grips world cframe for some reason as the cframe from the lookat is entirely fine
im still not sure why for some reason the orientation is reflected over some axis
skimming over it im not entirely sure its the same problem as me, looking at how similar their examples are it looks like an issue with computation and alignment stuff honestly i cant really grasp it when they start mentioning dot products and derivatives
i havent messed with it at all since ive been trying to get this to work, also i couldnt see it as a visible property to easily adjust so its probably 0,0,0
thats basically what ill fall back on if this doesn’t work, only issue is that im pretty sure its 100% falling through the map after i rip it of its grip and mess with it so ill probably just throw something hacky together