# Custom Rotation System

Hello, I have made my Custom Movement System already, but I am very confused on how I achieve a rotation system, for example: The Player holds W and D, their character is rotated around 45 degrees something like that, so I’m trying to achieve some sort of Rotational system that works with the keys and based on the camera’s lookvector aswell.

Not sure how your movement system works, but usually it’s just a matter of combining vectors. There’s better/more efficient ways of doing it, but say you have a Forward vector and a Right vector. To combine them you’d just have to add them together, then multiple the result by cos(45) or 0.7071. This would make movement the same speed but at a 45 deg angle.

e.g.

``````if Wdown and Ddown then
Velocity = (ForwardVect + RightVect)*0.7071
elseif Wdown
Velocity = ForwardVect
elseif Ddown then
Velocity = RightVect
end
``````

If that’s not what you need I’d be glad to help more if you want to provide some code

So basically that multiplied result I would put in the Y axis of like the CFrame.Angles() constructor?

``````CFrame.Angles(0, ResultVel * math.cos(45), 0)
``````

Would this be right or wrong?

Also, currently my movement system works by having 2 variables x and z, there’s also a variable called “off” which is used to describe the speed, if the player presses W it adds the off to the X, if a player holds D it adds the off to the z variable. Then inside of a function that is connected to a renderstepped event I keep setting the Body Velocity’s velocity to a variable called “Direction” which holds this value: `Direction = Vector3.new(CM.Camera.CFrame.LookVector.X * x, 0, CM.Camera.CFrame.LookVector.Z * x) + CM.Camera.CFrame.RightVector * z`
I hope this is enough info but if you need more I can add the rest of my code

I’m not familiar with CFrame.Angles, is it depreciated? To make a part point towards a certain direction I believe the method is setting it’s CFrame to it’s current positon and look vector could be your Direction vector

``````Part.CFrame = CFrame.new(Part.CFrame.Position, Direction)
``````

Is your movement system based on BodyMovers or CFraming?

I use a Body Gyro and a Body Velocity. And no CFrame.Angles() isn’t depreciated, it can be used to set the Body Gyro’s CFrame. Body Gyro is just a Body Mover that smoothly rotates something that’s how I think of it.

A body gyro is tricky to use - if you wish to use it for rotation, you have a few options:

1. Set body gyro to desired orientation (say, 45 degrees) at a low torque when a key is pressed
2. Lerp body gyro CFrame to desired orientation at a high torque (2 - 5 degrees per frame?)
3. Set velocity as DJX_D mentioned above. Note if you use this method and you continue to use a gyro, you will need to set the gyro orientation to match the current player orientation so it does not fight this change of orientation given by your `Part.CFrame` code. I can’t see why you would need a gyro in this case but as a heads up I leave it here for mentioning.

Hope this helps, sorry if this is a few days late, just got permission to post