Stopping player rotation / like anchored

  1. What do you want to achieve?
    Making the character face a certain direction without being able to rotate and after a set time it can rotate again freely. For my example its forward.

Gif of how i want it to be.

  1. What is the issue?
    The character is rotating freely during the move / weapon skill.
    https://media4.giphy.com/media/7tGVsktwgzrr55C6xC/giphy.gif

  2. What solutions have you tried so far?
    Tried using BodyGyro but didn’t work. I am a beginner and new to CFrames so it might be my mistake.

-- BodyGyro
local g = Instance.new("BodyGyro")
		
g.CFrame = CFrame.new(root.CFrame * Vector3.new(0,0,-1))
g.Parent = HumanoidRootPart

In the 1st Gif i am using bodyVelocity to move the character so i thought if i use Humanoid:MoveTo() and Humanoid.WalkSpeed = 0 can fix my problem but it made me move forward infinitely without stoping.

Humanoid.WalkSpeed = 0
Humanoid:MoveTo(root.CFrame * Vector3.new(0, 0, -1))

wait(3)

Humanoid.WalkSpeed = 16
Humanoid:MoveTo(root.CFrame * Vector3.new(0, 0, 0))
5 Likes

You can change the MaxForce on not used axes to 0. Doing that, it will rotate only on chosen specific axes.

2 Likes

A BodyGyro only applies torque to attempt to align the parent with the given orientation. I.e. it doesn’t apply force to move the parent. Because of this, the position component of the CFrame is completely ignored, and only the orientation component matters at all.

root.CFrame * Vector3.new(0,0,-1) evaluates to some Vector3

CFrame.new(root.CFrame * Vector3.new(0,0,-1)) evaluates to a CFrame whose position component is whatever the input Vector3 is, and whose rotation is 0.

The input component is ignored, so that whole line of code is equivalent to

g.CFrame = CFrame.new()

This should force the character to face forwards, because that’s the orientation of the “defaul” CFrame, assuming the character is physically simulated and the applied torque is strong enough. It shouldn’t do what you expect, but it should do something. I’m guessing this means the MaxTorque on the BodyGyro isn’t high enough. Try a really high value like 100000 or even higher to see if anything happens.

1 Like

Tried this and still 0 effect. Your comment is appreciated.

-- BodyGyro
local g = Instance.new("BodyGyro")
		
g.MaxTorque = Vector3.new(1000000,0,100000)

g.Parent = root

playAnim.Stopped:Connect(function()
g:Destroy()
end)

Doesn’t MaxForce effects only position ? And its for the bodyvelocity ? This is the bodyVelocity code.

-- BodyVelocity
local i = Instance.new("BodyVelocity")
		
i.MaxForce = Vector3.new(50000,0,50000)
i.Velocity = root.CFrame.lookVector * 60

All i want to know is. Do i can make it with bodyGyro ? So i can make sure i am searching in the right way. To make it more clear i want to make it like Anchored as in anchored you can’t rotate … etc.

You could disable/enable the Humanoid.AutoRotate property, which stops shift-lock from affecting the direction the player is facing.

Side note: the description of Humanoid.AutoRotate on the developer hub contradicts this, but don’t mind it, it still works just fine.

7 Likes