How would I go about making the character's hand point towards an attachment on an accessory?

Trying to set up a dynamic grip system for my game, where the player’s hands will automatically connect to the left and right grip attachments in the gun’s model (which is attached as an accessory)

I adapted this code from LMH_Hutch’s inverse kinematics guide

	local rightShoulderCFrame = Character["Right Arm"].CFrame * CFrame.new(1.5, 0.5, 0)
	local rightGoalPosition = game.Workspace["Model 12"].Handle.GripRight.Position

	local rightV3 = Vector3.new(0, 1, 0) * Character["Right Arm"].Size

	local planeCF, rightShoulderAngle, rightElbowAngle = SolveIK(rightShoulderCFrame, rightGoalPosition, rightV3.Y, 0)
	local rightShoulderAngleCFrame = CFrame.Angles(rightShoulderAngle, 0, 0)
	local rightElbowAngleAngleCFrame = CFrame.Angles(rightElbowAngle, 0, 0)

	Character["Right Arm"].CFrame = planeCF * rightShoulderAngleCFrame * CFrame.new(-rightV3 * 0.5)

…but it seems like the arm drags the entire rest of my character’s body with it and won’t move independently, even when targeting an object not attached to my character. I don’t really understand IK very well to begin with, so I’m wondering if there’s a simpler solution I’m not seeing.

3 Likes

Would it be possible to make this as an animation?

1 Like

that’s my fallback if I can’t get this working

might just do that tbh since this was supposed to save time making new assets and it’s currently doing the opposite lol

1 Like

For anyone here from google, I found this module by robert_stevey which did exactly what I needed.

I used two attachments inside the gun model for the left and right hands, and used the attachment position inside the WorldCFrame property as the target position for robert’s module. You’ll just need to edit the default ROBLOX animations to exclude the arms and stop them from flailing around when they’re supposed to be gripping your weapon.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.