Tilting a character on slopes without using root joints/welds

Messed around with BallSocketConstraints and created this little worm creature. In order to make the StarterCharacter work properly, I renamed the head part to HumanoidRootPart and made it the PrimaryPart of the model. For the most part, this works just fine:

However, the head now ignores any of the BallSocketConstraint physics. It just faces perfectly straight, which creates some jank when climbing a slope:

I tried using the solution of this post, which adjusts the head to the angle of the slope, but the effect is slow and introduces some jank of it’s own:

Basically, I still want the head to control as it currently does, but I also want the head to respect the physics of the BallSocketConstraint, or at the very least just look more natural when crawling up slopes.

Is there any way around this that doesn’t require overly-complex scripting?

1 Like

Funnily enough, anything that disables Humanoid physics (Sit, PlatformStand, EvaluateStateMachine) gives the exact result I want. Only issue is I can’t move, obviously.

I guess now the question is how can I stop the Humanoid from forcing the head upright without having to replace the entire movement system?

have you tried setting the humanoid state to physics?

Gives the same result as enabling PlatformStanding (can’t move the character)

Currently seeing if I can implement a basic set of controllers with this, though it’s gonna take some work. Tried using the scripts from this post and the StarterCharacter’s movement became very glitchy.

Not too sure if https://devforum.roblox.com/t/disablestop-humanoid-from-correcting-itself-at-an-angle/1056815/2 will help

I would imagine it would actually be pretty easy in your case to make an alternative movement system, since your character rig is already constrained by ball socket joints. I would start by applying forces to the head in different directions based on inputs and move from there. That might not be what you want overall, but it should allow you to match your head’s angle to the slope’s.

The solution in the post provided is on a wait(0.5) loop. Use RunService instead.

did that already, still takes too long to apply the effect. i should’ve mentioned that in the post sorry

saw that before making the post. definitely keeping the Wallstick module in mind, but it’s gonna take some work to tweak it to what I need. was hoping there was some easier solution before i commit to that

Alright here’s the solution:

Firstly, I welded a part to the head that sticks out slightly in-front to detect slopes, since the Humanoid was giving the head some weird collision.

Then, I used the script from this post (turned out to be the solution after all) and added a Tween to smoothen the angle correction:

--put this in StarterCharacterScripts
local char = script.Parent
local rootPart = char:WaitForChild("HumanoidRootPart") --head
local detector = char:WaitForChild("detector") --part i welded to head
local xzGyro = Instance.new("BodyGyro")
xzGyro.MaxTorque = Vector3.new(3e5,0,3e5)
xzGyro.P = 5e5
xzGyro.Parent = rootPart

tweenservice = game:GetService("TweenService")
--removed the TweenInfo from the example because it wasn't relevant

game:GetService("RunService").RenderStepped:Connect(function()
	local params = RaycastParams.new()
	params.FilterDescendantsInstances = {char}
	params.FilterType = Enum.RaycastFilterType.Exclude
	local result = workspace:Raycast(detector.Position, Vector3.new(0,-10,0), params)
	if (result) then
		local currentRightVector = detector.CFrame.RightVector
		local upVector = result.Normal
		local newFacialVector = currentRightVector:Cross(upVector)
		local tween = tweenservice:Create(xzGyro, tweenInfo, {CFrame = CFrame.fromMatrix(detector.Position, currentRightVector, upVector, newFacialVector)})
		tween:Play()
	end
end)

If you’re seeing this in the future and this script doesn’t work, it’s probably because BodyGyro is deprecated. I tried to figure out how to update it using AlignOrientation instead but I’m lazy and kind of an idiot…

Anyway, the script isn’t completely perfect but it’s a good starting point for what I need. Here’s a vid of the script in-action

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