Wiki Weapons Kit character tilt on unequip

1. What do you want to achieve? Keep it simple and clear!

I would like to know if anyone else has run into/found a solution to this issue.

2. What is the issue? Include screenshots / videos if possible!

When using the weapons kit from the wiki, (Weapons Kit) if you unequip a weapon while walking, it leaves your character tilting backward like this:

helpTopic

I highlighted the HRP to help show the difference in angle. If you stop walking, then unequip the weapon, the character stays normal.

3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I’ve googled quite a bit, and searched through the topics on this forum but didn’t find anything.

I spent a few hours tweaking code in various places within the ShoulderCamera library. (things like pitch/yaw)

I implemented a workaround where on unequip, the player’s speed is adjusted to 0 and they’re anchored for a split second, which helped a little. Has anyone else run into this issue?

fyi - Commenting out the two places in ShoulderCamera library, where self:applyRootJointFix()
is called, stopped this behavior. The weapon does bounce up and down more, but it still might be worth having this commented out.

-- This function keeps the held weapon from bouncing up and down too much when you move
function ShoulderCamera:applyRootJointFix()
	if self.rootJoint then
		local translationScale = self.zoomState and Vector3.new(0.25, 0.25, 0.25) or Vector3.new(0.5, 0.5, 0.5)
		local rotationScale = self.zoomState and 0.15 or 0.2
		local rootRotation = self.rootJoint.Part0.CFrame - self.rootJoint.Part0.CFrame.Position
		local rotation = self.rootJoint.Transform - self.rootJoint.Transform.Position
		local yawRotation = CFrame.Angles(0, self.yaw, 0)
		local leadRotation = rootRotation:toObjectSpace(yawRotation)
		local rotationFix = self.rootRigAttach.CFrame
		if self:isHumanoidControllable() then
			rotationFix = self.rootJoint.Transform:inverse() * leadRotation * rotation:Lerp(CFrame.new(), 1 - rotationScale) + (self.rootJoint.Transform.Position * translationScale)
		end

		self.rootJoint.C0 = CFrame.new(self.rootJoint.C0.Position, self.rootJoint.C0.Position + rotationFix.LookVector.Unit)
	end
end
1 Like

Here’s a better solution to the character tilting problem (just came up with it now for my own modified weapon kit)…

I wanted to keep the applyRootJointFix() function as the weapon bouncing up and down looks just as bad as the character tilting.

Add a new attribute to the ShoulderCamera constructor: e.g. self.tiltFix, and initialise to nil.

Now, inside applyRootJointFix(), before this line…

self.rootJoint.C0 = CFrame.new(self.rootJoint.C0.Position, self.rootJoint.C0.Position + rotationFix.LookVector.Unit)

add this line, so that we have the original C0 CFrame value stored.

if not self.tiltFix then self.tiltFix = self.rootJoint.C0 end

Now, when the weapon is unequipped, set rootJoint.C0 to the tiltFix CFrame value. For example, I have this line in a LocalScript, connected to the Unequipped event:

weaponModule.camera.rootJoint.C0 = weaponModule.camera.tiltFix
3 Likes

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