Rotating the player using physics?

Hey there! Currently developing my game and i’m trying to figure out how to make rotate slightly while there floating in 0 gravity, I’ve tried most methods, but I haven’t found any solutions. If you could give me insight on how to do this it would be very helpful! As you can see in the video I recreated it using my character to nudge it, anyway to do this in script?

1 Like

Rotating it could’ve been easy if you used TweenService with modification of the CFrame, but with physics? Try AlignOrientation.

1 Like

How would I implement this, very new to physics related stuff haha.

The HumanoidRootPart needs an attachment connected to AlignOrientation, with its Mode property set to OneAttachment. Suppose you want the character to turn rapidly, set Responsiveness to 200. That’s pretty much it.

1 Like

You should use AngularVelocity if you want to purely use the physics system. What AlignOrientation does is essentially lerp a CFrame, so you’ll need to calculate the desired final orientation of the character for it to work at all. AngularVelocity, on the other hand, just applies a force to make a part rotate, which doesn’t require any calculations and thus is easier and more dynamic.

1 Like

This is still in beta but it should work

1 Like

Ah I see! How would that look in code?

1 Like

You just need to make an attachment in the humanoid root part, then you can assign it to the AngularVelocity object. From there you just set the properties you want: raise the max torque to whatever you want and then set a torque with a Vector3. If you want the character to spin horizontally then just set a value to the X or Z axis. You’ll probably have to fiddle with the properties to find a value that works well.

Correction: you should apply the torque on the Y axis if you want to rotate horizontally. My bad!

3 Likes

Thank you! This work! Time to implement the rest of this script, thank you :smile:

1 Like

@Rodtodon @SomeFedoraGuy

I just wanted to give some clarity/corrections on the discussion here.

First, both AlignOrientation and AngularVelocity are constraints that will create movement via simulation. Unless you set “RigidityEnabled” on the AlignOrientation to true.

AlignOrientation has some goal orientation, and will apply torque to reach that orientation goal and maintain it. You can configure it to align on one, two, or all three axes. If RigidityEnabled is true, then it’s not applying torque, its only applying positional correction (essentially cframing)

An AngularVelocity has some goal angular velocity. So it applies a torque to keep the part at the defined velocity, thus having it constantly rotate.

For your use case, it sounds like AngularVelocity (as explained by @Rodtodon) is the one you should choose.

You can find more info on these constraints and other “mover” constraints here:
https://create.roblox.com/docs/building-and-visuals/physics/mover-constraints

2 Likes