Making a custom character controller - anyone have any idea how to achieve this "tilt" effect?



I’m creating a character controller using @Quenty’s spring module, and while I was able to achieve the gradual speeding up and slowing down motion that I desired, I’m clueless on how to achieve the tilt seen in the videos above. I think the first video shows it best - it’s almost as if the character is drawn towards a central point and tilts accordingly. I was hoping that someone might be able to point me in the right direction. Thanks.

1 Like

I’m pretty sure what you have to do is to play around with RootJoint motor6d stored in lower torso/humanoid root part, depending on the rig type you’re using. Essentially you would have to set it’s C0 based on humanoid’s MoveDirection property.

1 Like

Checkout this code here in the DNS Drone Project I worked on.

3 Likes

So there are a number of ways to do this.

The easiest way is to use the built in RotVelocity property that baseparts have. Using this you can measure how fast the character is spinning on the y-axis and then convert that into an actual tilt angle.

As was mentioned above this is best applied to the character’s root joint’s C0 or C1 value.

Here’s a general idea of the code:

function CharacterTilt:GetAccelerationTiltCF()
	if (self.AccelerationTilt) then
		-- can adjust the literal `2` value to something else, this will change the intensity of the tilt
		if (self.IsR15) then
			return CFrame.fromEulerAnglesXYZ(0, 0, math.rad(-self.HRP.RotVelocity.y * 2))
		else
			return CFrame.fromEulerAnglesXYZ(0, math.rad(-self.HRP.RotVelocity.y * 2), 0)
		end
	end
	return IDENTITY
end

function CharacterTilt:Update(dt)
	self.AccelerationTiltCF = self.AccelerationTiltCF:Lerp(self:GetAccelerationTiltCF(), 0.1)
	self.RootJoint.C1 = self.AccelerationTiltCF
end

Attached is an example place file. There are a few extra things in there, but I’ve disabled it so it should only be the tilt.

CharacterTilt.rbxl (24.2 KB)

18 Likes