Due to the nature of my game, I need to make a custom character control for it. It’s basically already done, however, the character stops moving and jags really weird everytime I turn around. I was turning around by directly setting the HumanoidRootPart CFrame, but I read something about AlignOrientation and attempted to use it. Sadly, still isn’t working.
My current code for setting my AlignOrientation is:
local char = script.Parent
local root = char:WaitForChild("HumanoidRootPart")
local part = Instance.new("Part")
local att = Instance.new("Attachment")
local align = Instance.new("AlignOrientation")
local weld = Instance.new("WeldConstraint")
part.Name = "RotationOrigin"
part.Size = Vector3.one * 0.25
part.Shape = Enum.PartType.Ball
part.Transparency = 1
part.CanCollide = false
part.CanTouch = false
part.CanQuery = false
part.CastShadow = false
part.Parent = char
part.CFrame = root.CFrame
weld.Name = "RotationWeld"
weld.Part0 = root
weld.Part1 = part
weld.Parent = part
att.Parent = part
align.Name = "Rotator"
align.Attachment0 = root:WaitForChild("RootAttachment")
align.Attachment1 = att
align.PrimaryAxisOnly = true
align.Parent = char
And I move the RotationOrigin like this:
if cam.X ~= 0 then
rotator.CFrame = rotator.CFrame * CFrame.Angles(0, math.rad(-cam.X * 0.5), 0)
end
I’ve looked around and it seems that everytime the CFrame is set, the character will stop moving as position is updated. Isn’t there anyway to rotate the character without canceling Humanoid:Move()?
I understand that you are working with CFrame manipulation in the context of a physics system or character movement in some development environment. Using AlignOrientation is a useful technique for adjusting an object’s orientation in space, but it may need to be set correctly for it to work as intended.
Here is an example of how you can use AlignOrientation in Roblox (Lua) to adjust the orientation of a HumanoidRootPart:
– Assuming ‘humanoid’ is a reference to the character’s Humanoid
local humanoid = game.Workspace:WaitForChild(“YourCharacterName”):FindFirstChild(“Humanoid”)
– Assume ‘desiredOrientation’ is the desired orientation in CFrame
local desiredOrientation = CFrame.new(Vector3.new(0, 0, 0)) – Replace with desired CFrame
– Use AlignOrientation to adjust the orientation of the HumanoidRootPart
I checked the docs and is a boolean, used to set if must be referent to the camera or not. In your example code u are sending a CFrame. Does it have more than one use? I can’t find anything about that in the docs.
Woah, cool guide and cool work! However I’m not sure if this is gonna work for me. My movement isn’t physics based and the reasons why I’m making my custom controller are the same reason it would be difficult to work with this. But thanks nontheless, I might take some code if I think it fits my needs.
My problem is on how could I rotate my character without setting the CFrame, because it will stop the current :Move()
I have the feeling I’m gonna have to play around the RunService and play the animations myself :C I wanted to try and hook the displacement part on Roblox’s default movement methods.
Oh ok that gives me an idea, I will make a “Dirt” system where everytime the character CFrame is rotated it sets a variable dirty, in the next physics frame it will update Move again if it’s dirty, lemme see if it doesn’t break anims or anything else.