How do i set the Rotational CFrame of the Character without setting the Position?

In the video my character is not moving as fast as he should. This is because i set the Characters Rotation everytime the LookVector it exceeds a certain amount and when he changes direction. This makes sure that the character is always looking Left or Right perfectly.

The only problem is my character keeps getting its position set every :RenderStepped(). How do i set the Rotational CFrame without the position??

My code:

local function CameraStepped()
			print(HumanoidRootPart.CFrame.LookVector.X)
	
			if leftValue == 1  then
				HumanoidRootPart.CFrame =  CFrame.new(HumanoidRootPart.Position, Vector3.new(-90,0,0))		
			end
		
		
			if HumanoidRootPart.CFrame.LookVector.X > -0.95 and HumanoidRootPart.CFrame.LookVector.X < 0 then
				--///Turn Left
				HumanoidRootPart.CFrame =  CFrame.new(HumanoidRootPart.Position, Vector3.new(-90,0,0))
			end
			if HumanoidRootPart.CFrame.LookVector.X < 0.95 and HumanoidRootPart.CFrame.LookVector.X > 0 then
				--///Turn Right
				HumanoidRootPart.CFrame =  CFrame.new(HumanoidRootPart.Position, Vector3.new(90,0,0)) 
			end	
				
			if rightValue == 1 then			
				HumanoidRootPart.CFrame =  CFrame.new(HumanoidRootPart.Position, Vector3.new(90,0,0)) 			
			end
		end
		````

Instead of setting the CFrame, you could just set the Orientation of he HumanoidRootPart.

You can try CFrame.Angles

HumanoidRootPart.CFrame = HumanoidRootPart.CFrame * CFrame.Angles(angles here)

i tried this i ended up with super glitchy results.

In what way glitchy? It should work fine.

i keep falling down and moving weirldly. I dont know why either

1 Like

this was the result, its probably because it keeps multiplying the angle therefore making him continuously rotate

This is probably happening because you introduced a wrong value. CFrame.Angles accepts values in radians. If you put a big number (eg 90), the resulting LookVector will most likely be smaller than 0.95 and bigger than -0.95, forcing the character to rotate every frame.

Try using something like CFrame.Angles(0, .5*math.pi, 0)

alright, i see what you mean but i get the same results. I dont know what im doing wrong tho. I took that code exactly.

I recommend not setting the CFrame/rotation, but letting the character move on its own. You can override the default humanoid movement and manually use Move to make the character move. To do this, get input from the a and d keys and move the character only to the left or right.

If you are worried about something pushing the character off the edge, you can try using a constraint or maybe an old body mover if you have to.

There should be a tutorial somewhere with more details on how to do this.

Also, if you don’t want to change the code you have, you can rotate the character with constraints or maybe body movers.

Thing is i want the character to turn faster. So i disable autorotate and use CFrame.

How would i use constraints by the way? bodygyro doesnt really work well.

I tried the BodyGyro, and it worked for me. Be sure to set its CFrame and adjust the power, toque, etc as needed.

I did, and i still get glitchy results, because of the position as mentioned in the title of the question

I don’t recommend manually setting the character’s CFrame or position.