Convert MoveDirection into CFrame.Angles

I have a rolling system in game, and I want it to roll wherever the player is moving. My solution to this is to use HumanoidRootPart.CFrame.LookVector * CFrame.Angles()
However, my question is how would I be able to convert the humanoid’s MoveDirection into a CFrame.Angles for me to use?

I’ve tried just using the movement keys WASD but that doesn’t take mobile players into consideration.

2 Likes

Are you making a movement mechanic similar to Super Monkey Ball?

You’ll want to apply a torque on the ball that’s perpendicular to the desired movement direction. It should also be horizontal, which is equivalent to being perpendicular to the vertical direction. This means you can calculate the axis around which to rotate the ball like so:

local rotateAxis = moveDirection:Cross(Vector3.yAxis).Unit

Given a rotation axis, you can compute the CFrame that represents a rotation about that axis like so:

local rotateCFrame = CFrame.fromAxisAngles(rotateAxis, rotationAmount)

rotationAmount is a number representing how many radians to rotate.

1 Like


it gives me this error, this is my code:

1 Like

Please include the line numbers in the screenshot

Whoops, it’s fromAxisAngle (no ‘s’)

there are no longer errors, however it still isn’t working. it simply rolls forward every time

Just to be sure, is this the kind of movement you’re going for?

nope, it’s just normal roblox movement, however, upon pressing C, the character will quickly roll/dash in the direction the character is moving in (thats what im going for at least)

Then can’t you just replace HumanoidRootPart.CFrame.LookVector with humanoid.MoveDirection?

2 Likes

i cant believe i didnt realize this sooner…

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.