I want to tilt a character in a similar way to how they do when they swim (it’s for a swimming script), how do I do this?
not sure by what criteria you want to tilt the character and by how much, but the actual tilting can be done like this
character.HumanoidRootPart.RootJoint.C1 =
character.HumanoidRootPart.RootJoint.C1*CFrame.Angles(math.rad(-90),0,0)
the above code should tilt the player forwards by 90 degrees, and not impede their movement
Characters always want to return to an upright position.
I’ve tested this in studio and it works as I expect it to, specifically tilting the player visually and not affecting movement whatsoever
by changing the rootjoint’s offset values I don’t exactly set the character’s orientation forcedfully, but how it is displayed relative to the humanoidrootpart, which I suppose stays otherwise unaffected, and therefore not impeding normal movement
Ah, that’s a clever solution.
for testing purposes I even tried rotating the character fully upside down, and I have noticed no unusual behaviour, at most making the animations look goofy
but for the purpose of this question I recorded a GIF showing how it looks like rotated forwards by 90 degrees
edit: replaced with a gfycat link (I suppose it’s alright?) due to lack of knowledge on how to upload an animated gif directly to the site
https://gfycat.com/AmazingHarmoniousBarb
A couple of things to note:
-
This code is R6-specific. On R15 the equivalent joint is LowerTorso.Root
-
This code must be in a server script for everyone to see the character tilted, a LocalScript change to Root.C1 won’t replicate to the server. The consequence of this is lack of responsive feel if player input is meant to directly cause the flip.
-
If you want to initiate this type of flip on the client, the easiest way is to bake the rotation into an animation if you can. This is the preferred solution for swimming, sleeping, crawling, being prone while sniping, etc. where you have only specific animations that need to be tilted in one specific way. It’s not how you’d go about trying to say, make any walk or run tilt a character on a banked track or running on a slope.
Doesn’t seem to work?
local localPlayer = game:GetService("Players").LocalPlayer
local Character = localPlayer.Character or localPlayer.CharacterAdded:wait()
local lowerTorso = Character:WaitForChild("LowerTorso")
game:GetService("RunService").RenderStepped:Connect(function()
lowerTorso.Root.C1 = lowerTorso.Root.C1*CFrame.Angles(math.rad(-90),0,0)
end)
What are you expecting that to do? It’s rotating the character on every frame, so I’d expect it to look a bit frantic. If the goal is to re-orient the character, you only want to make that adjustment one time, not every frame.
Apparently R15 doesn’t have a RootJoint, what’d you do then if you don’t mind me asking